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)
content_html = add_user_links(content, mentions)
+ date = make_date()
+
activity = %{
"type" => "Create",
"to" => to,
"content" => content_html,
"published" => date,
"context" => context,
- "attachment" => attachments
+ "attachment" => attachments,
+ "actor" => user.ap_id
},
"published" => date,
"context" => context
end
def fetch_friend_statuses(user, opts \\ %{}) do
- ActivityPub.fetch_activities(user.following, opts)
+ ActivityPub.fetch_activities([user.ap_id | user.following], opts)
|> activities_to_statuses(%{for: user})
end
{ :ok, activity } <- ActivityPub.insert(%{
"type" => "Follow",
"actor" => follower.ap_id,
- "object" => followed.ap_id
+ "object" => followed.ap_id,
+ "published" => make_date()
})
do
{ :ok, follower, followed, activity }
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