Transmogrifier: Remove ChatMessageHandling module.
authorlain <lain@soykaf.club>
Wed, 29 Apr 2020 11:52:23 +0000 (13:52 +0200)
committerlain <lain@soykaf.club>
Wed, 29 Apr 2020 11:52:23 +0000 (13:52 +0200)
lib/pleroma/web/activity_pub/side_effects.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex [deleted file]

index 794a462678f9772daf81eb976b052d634252fd6d..e394c75d7d36bce85e606df8929c4a3da5d7699a 100644 (file)
@@ -19,17 +19,12 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
   # - Add like to object
   # - Set up notification
   def handle(%{data: %{"type" => "Like"}} = object, meta) do
-    {:ok, result} =
-      Pleroma.Repo.transaction(fn ->
-        liked_object = Object.get_by_ap_id(object.data["object"])
-        Utils.add_like_to_object(object, liked_object)
+    liked_object = Object.get_by_ap_id(object.data["object"])
+    Utils.add_like_to_object(object, liked_object)
 
-        Notification.create_notifications(object)
+    Notification.create_notifications(object)
 
-        {:ok, object, meta}
-      end)
-
-    result
+    {:ok, object, meta}
   end
 
   # Tasks this handles
index 66975cf7db3b9a030521075c19a20815a0a4d769..3c2fe73a35259d68daab776eb0c5d85ec5896634 100644 (file)
@@ -16,7 +16,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   alias Pleroma.Web.ActivityPub.ObjectValidator
   alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
   alias Pleroma.Web.ActivityPub.Pipeline
-  alias Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageHandling
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.Federator
@@ -646,9 +645,16 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
 
   def handle_incoming(
         %{"type" => "Create", "object" => %{"type" => "ChatMessage"}} = data,
-        options
-      ),
-      do: ChatMessageHandling.handle_incoming(data, options)
+        _options
+      ) do
+    case Pipeline.common_pipeline(data, local: false) do
+      {:ok, activity, _} ->
+        {:ok, activity}
+
+      e ->
+        e
+    end
+  end
 
   def handle_incoming(%{"type" => "Like"} = data, _options) do
     with {_, {:ok, cast_data_sym}} <-
diff --git a/lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex b/lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex
deleted file mode 100644 (file)
index b1cc934..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageHandling do
-  alias Pleroma.Web.ActivityPub.Pipeline
-
-  def handle_incoming(
-        %{"type" => "Create", "object" => %{"type" => "ChatMessage"}} = data,
-        _options
-      ) do
-    case Pipeline.common_pipeline(data, local: false) do
-      {:ok, activity, _} ->
-        {:ok, activity}
-
-      e ->
-        e
-    end
-  end
-end