Assorted fixes.

This commit is contained in:
lain 2018-11-30 17:08:02 +01:00
parent d407f662af
commit 48b95a9b95
5 changed files with 19 additions and 15 deletions

View file

@ -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 @@ def remote_user_creation(info, params) do
:banner,
:locked,
:magic_key,
:uri
:uri,
:hub,
:topic
])
end

View file

@ -146,7 +146,7 @@ defp valid_topic(%{"hub.topic" => topic}, user) 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 @@ def subscribe(subscriber, subscribed, requester \\ &request_subscription/1) 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(),

View file

@ -447,7 +447,7 @@ test "it works for atom notes, too" 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)

View file

@ -31,10 +31,10 @@ test "A user with emoji in username", %{user: user} 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 @@ test "A user with emoji in username", %{user: user} 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 @@ test "A user" 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 @@ test "A user that follows you", %{user: user} 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 @@ test "a user with mastodon fields" do
user =
insert(:user, %{
info: %{
"source_data" => %{
source_data: %{
"attachment" =>
Enum.map(fields, fn field -> Map.put(field, "type", "PropertyValue") end)
}

View file

@ -99,7 +99,7 @@ def accepting_verifier(subscription) 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]