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
:banner,
:locked,
:magic_key,
- :uri
+ :uri,
+ :hub,
+ :topic
])
end
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) <-
_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(),
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)
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",
}
]
}
- }
- }
+ },
+ name: ":karjalanpiirakka: man"
+ })
- user = %{user | name: ":karjalanpiirakka: man"}
represented = UserView.render("show.json", %{user: user})
assert represented["name_html"] == expected
end
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"
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"]
user =
insert(:user, %{
info: %{
- "source_data" => %{
+ source_data: %{
"attachment" =>
Enum.map(fields, fn field -> Map.put(field, "type", "PropertyValue") end)
}
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]