diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-05-07 14:45:37 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-05-07 14:45:37 +0200 |
commit | a41aa4e4898660fffb9a54070d16e2c3a5373d71 (patch) | |
tree | 0046a2ebca32a257f127888f3068e6ff9dffcca4 /lib | |
parent | 95ab0dc3c5ea63048a98b5fb594d0163249be822 (diff) | |
download | pleroma-a41aa4e4898660fffb9a54070d16e2c3a5373d71.tar.gz |
Federate follow salmons.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/ostatus/activity_representer.ex | 28 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api.ex | 3 |
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index 717670852..076ead41a 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -118,6 +118,34 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do ] ++ mentions ++ author end + def to_simple_form(%{data: %{"type" => "Follow"}} = activity, user, with_author) do + h = fn(str) -> [to_charlist(str)] end + + updated_at = activity.updated_at + |> NaiveDateTime.to_iso8601 + inserted_at = activity.inserted_at + |> NaiveDateTime.to_iso8601 + + author = if with_author, do: [{:author, UserRepresenter.to_simple_form(user)}], else: [] + + mentions = activity.data["to"] |> get_mentions + [ + {:"activity:object-type", ['http://activitystrea.ms/schema/1.0/activity']}, + {:"activity:verb", ['http://activitystrea.ms/schema/1.0/follow']}, + {:id, h.(activity.data["id"])}, + {:title, ['#{user.nickname} started following #{activity.data["object"]}']}, + {:content, [type: 'html'], ['#{user.nickname} started following #{activity.data["object"]}']}, + {:published, h.(inserted_at)}, + {:updated, h.(updated_at)}, + {:"activity:object", [ + {:"activity:object-type", ['http://activitystrea.ms/schema/1.0/person']}, + {:id, h.(activity.data["object"])}, + {:uri, h.(activity.data["object"])}, + ]}, + {:link, [rel: 'self', type: ['application/atom+xml'], href: h.(activity.data["id"])], []}, + ] ++ mentions ++ author + end + def wrap_with_entry(simple_form) do [{ :entry, [ diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 71f0c366e..3921c0d74 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -139,10 +139,13 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do {:ok, activity} <- ActivityPub.insert(%{ "type" => "Follow", "actor" => follower.ap_id, + "to" => [followed.ap_id], "object" => followed.ap_id, "published" => make_date() }) do + # TODO move all this to ActivityPub + Pleroma.Web.Federator.enqueue(:publish, activity) {:ok, follower, followed, activity} else err -> err |