Don't return html in the text field.
[akkoma] / lib / pleroma / web / twitter_api / twitter_api.ex
index 2aaa73b78ff4fde7249cbc332d39606082d8def6..0217b28d64139a815636f36a3908b3e1605fd732 100644 (file)
@@ -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,
@@ -69,7 +69,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
   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
 
@@ -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