diff options
author | lambadalambda <gitgud@rogerbraun.net> | 2017-04-10 08:44:19 -0400 |
---|---|---|
committer | lambadalambda <gitgud@rogerbraun.net> | 2017-04-10 08:44:19 -0400 |
commit | b5e94bf9301713fd9eb3b80dbcf64ae6782092bc (patch) | |
tree | 71f83f23cc47ae1058bdb26b23f12277c31acf7b /lib/pleroma/web/twitter_api/twitter_api.ex | |
parent | 567ec494c523ded79c69f4d1bb0be9e51ca09837 (diff) | |
parent | 0016589aea391fd6b8d41257b7f39f76b5b93775 (diff) | |
download | pleroma-b5e94bf9301713fd9eb3b80dbcf64ae6782092bc.tar.gz |
Merge branch 'develop' into 'develop'
Add Follow activity insertion
See merge request !1
Diffstat (limited to 'lib/pleroma/web/twitter_api/twitter_api.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api.ex | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 2aaa73b78..0a942e880 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -6,8 +6,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do import Ecto.Query def create_status(user = %User{}, data = %{}) do - date = DateTime.utc_now() |> DateTime.to_iso8601 - attachments = Enum.map(data["media_ids"] || [], fn (media_id) -> Repo.get(Object, media_id).data end) @@ -27,6 +25,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do content_html = add_user_links(content, mentions) + date = make_date() + activity = %{ "type" => "Create", "to" => to, @@ -103,9 +103,15 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do def follow(%User{} = follower, followed_id) do with %User{} = followed <- Repo.get(User, followed_id), - { :ok, follower } <- User.follow(follower, followed) + { :ok, follower } <- User.follow(follower, followed), + { :ok, activity } <- ActivityPub.insert(%{ + "type" => "Follow", + "actor" => follower.ap_id, + "object" => followed.ap_id, + "published" => make_date() + }) do - { :ok, follower, followed } + { :ok, follower, followed, activity } end end @@ -178,4 +184,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do mentioned_users = Repo.all(from user in User, where: user.ap_id in ^activity.data["to"]) ActivityRepresenter.to_map(activity, Map.merge(opts, %{user: user, mentioned: mentioned_users})) end + + defp make_date do + DateTime.utc_now() |> DateTime.to_iso8601 + end end |