mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 16:40:29 +00:00
Assorted fixes.
This commit is contained in:
parent
d407f662af
commit
48b95a9b95
5 changed files with 19 additions and 15 deletions
|
@ -20,6 +20,8 @@ defmodule Pleroma.User.Info do
|
|||
field(:settings, :map, default: nil)
|
||||
field(:magic_key, :string, default: nil)
|
||||
field(:uri, :string, default: nil)
|
||||
field(:topic, :string, default: nil)
|
||||
field(:hub, :string, default: nil)
|
||||
# topic, subject, salmon, subscribe_address, uri
|
||||
end
|
||||
|
||||
|
@ -99,7 +101,9 @@ defmodule Pleroma.User.Info do
|
|||
:banner,
|
||||
:locked,
|
||||
:magic_key,
|
||||
:uri
|
||||
:uri,
|
||||
:hub,
|
||||
:topic
|
||||
])
|
||||
end
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ defmodule Pleroma.Web.Websub do
|
|||
end
|
||||
|
||||
def subscribe(subscriber, subscribed, requester \\ &request_subscription/1) do
|
||||
topic = subscribed.info["topic"]
|
||||
topic = subscribed.info.topic
|
||||
# FIXME: Race condition, use transactions
|
||||
{:ok, subscription} =
|
||||
with subscription when not is_nil(subscription) <-
|
||||
|
@ -158,7 +158,7 @@ defmodule Pleroma.Web.Websub do
|
|||
_e ->
|
||||
subscription = %WebsubClientSubscription{
|
||||
topic: topic,
|
||||
hub: subscribed.info["hub"],
|
||||
hub: subscribed.info.hub,
|
||||
subscribers: [subscriber.ap_id],
|
||||
state: "requested",
|
||||
secret: :crypto.strong_rand_bytes(8) |> Base.url_encode64(),
|
||||
|
|
|
@ -447,7 +447,7 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
end
|
||||
end
|
||||
|
||||
test "it doesn't add nil in the do field" do
|
||||
test "it doesn't add nil in the to field" do
|
||||
incoming = File.read!("test/fixtures/nil_mention_entry.xml")
|
||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
expected =
|
||||
"<img height=\"32px\" width=\"32px\" alt=\"karjalanpiirakka\" title=\"karjalanpiirakka\" src=\"/file.png\" /> man"
|
||||
|
||||
user = %{
|
||||
user
|
||||
| info: %{
|
||||
"source_data" => %{
|
||||
user =
|
||||
insert(:user, %{
|
||||
info: %{
|
||||
source_data: %{
|
||||
"tag" => [
|
||||
%{
|
||||
"type" => "Emoji",
|
||||
|
@ -43,10 +43,10 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
name: ":karjalanpiirakka: man"
|
||||
})
|
||||
|
||||
user = %{user | name: ":karjalanpiirakka: man"}
|
||||
represented = UserView.render("show.json", %{user: user})
|
||||
assert represented["name_html"] == expected
|
||||
end
|
||||
|
@ -103,7 +103,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
end
|
||||
|
||||
test "A user for a given other follower", %{user: user} do
|
||||
{:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
|
||||
follower = insert(:user, %{following: [User.ap_followers(user)]})
|
||||
{:ok, user} = User.update_follower_count(user)
|
||||
image = "http://localhost:4001/images/avi.png"
|
||||
banner = "http://localhost:4001/images/banner.png"
|
||||
|
@ -186,7 +186,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
end
|
||||
|
||||
test "a user that is a moderator" do
|
||||
user = insert(:user, %{info: %{"is_moderator" => true}})
|
||||
user = insert(:user, %{info: %{is_moderator: true}})
|
||||
represented = UserView.render("show.json", %{user: user, for: user})
|
||||
|
||||
assert represented["rights"]["delete_others_notice"]
|
||||
|
@ -250,7 +250,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
user =
|
||||
insert(:user, %{
|
||||
info: %{
|
||||
"source_data" => %{
|
||||
source_data: %{
|
||||
"attachment" =>
|
||||
Enum.map(fields, fn field -> Map.put(field, "type", "PropertyValue") end)
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ defmodule Pleroma.Web.WebsubTest do
|
|||
|
||||
test "initiate a subscription for a given user and topic" do
|
||||
subscriber = insert(:user)
|
||||
user = insert(:user, %{info: %{"topic" => "some_topic", "hub" => "some_hub"}})
|
||||
user = insert(:user, %{info: %Pleroma.User.Info{topic: "some_topic", hub: "some_hub"}})
|
||||
|
||||
{:ok, websub} = Websub.subscribe(subscriber, user, &accepting_verifier/1)
|
||||
assert websub.subscribers == [subscriber.ap_id]
|
||||
|
|
Loading…
Reference in a new issue