AP refactoring.
[akkoma] / lib / pleroma / web / ostatus / ostatus.ex
index 1ac38bd8af16c3c0a90b06bd8215fc3ae720907b..949b36664d921722ce08d0894afa84ce41cfd36b 100644 (file)
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.OStatus do
 
   alias Pleroma.{Repo, User, Web, Object, Activity}
   alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.{WebFinger, Websub}
   alias Pleroma.Web.OStatus.FollowHandler
 
@@ -158,7 +159,7 @@ defmodule Pleroma.Web.OStatus do
                 if String.length(context) > 0 do
                   context
                 else
-                  ActivityPub.generate_context_id
+                  Utils.generate_context_id
                 end
               end
 
@@ -235,8 +236,12 @@ defmodule Pleroma.Web.OStatus do
         info: info,
         avatar: info["avatar"]
       }
-      cs = User.remote_user_creation(data)
-      Repo.insert(cs)
+      with %User{} = user <- User.get_by_ap_id(data.ap_id) do
+        {:ok, user}
+      else _e ->
+        cs = User.remote_user_creation(data)
+        Repo.insert(cs)
+      end
     end
   end