ChatMessageReference -> Chat.MessageReference
authorlain <lain@soykaf.club>
Sat, 6 Jun 2020 09:51:10 +0000 (11:51 +0200)
committerlain <lain@soykaf.club>
Sat, 6 Jun 2020 09:51:10 +0000 (11:51 +0200)
14 files changed:
lib/pleroma/chat/message_reference.ex [moved from lib/pleroma/chat_message_reference.ex with 98% similarity]
lib/pleroma/web/activity_pub/side_effects.ex
lib/pleroma/web/mastodon_api/views/notification_view.ex
lib/pleroma/web/pleroma_api/controllers/chat_controller.ex
lib/pleroma/web/pleroma_api/views/chat/message_reference_view.ex [moved from lib/pleroma/web/pleroma_api/views/chat_message_reference_view.ex with 95% similarity]
lib/pleroma/web/pleroma_api/views/chat_view.ex
lib/pleroma/web/streamer/streamer.ex
test/chat/message_reference_test.exs [moved from test/chat_message_reference_test.exs with 82% similarity]
test/web/activity_pub/side_effects_test.exs
test/web/mastodon_api/views/notification_view_test.exs
test/web/pleroma_api/controllers/chat_controller_test.exs
test/web/pleroma_api/views/chat/message_reference_view_test.exs [moved from test/web/pleroma_api/views/chat_message_reference_view_test.exs with 77% similarity]
test/web/pleroma_api/views/chat_view_test.exs
test/web/streamer/streamer_test.exs

similarity index 98%
rename from lib/pleroma/chat_message_reference.ex
rename to lib/pleroma/chat/message_reference.ex
index 6e836cad9cc79ba5f062e564e4c29b73b40e9983..4b201db2e5f42012e08600caf6495477d62ce563 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.ChatMessageReference do
+defmodule Pleroma.Chat.MessageReference do
   @moduledoc """
   A reference that builds a relation between an AP chat message that a user can see and whether it has been seen
   by them, or should be displayed to them. Used to build the chat view that is presented to the user.
index 5258212ecea2eb63ff861442945a7ed5a3793804..1e9d6c2fca5c59cde018936cb008deac6c754422 100644 (file)
@@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
   """
   alias Pleroma.Activity
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Notification
   alias Pleroma.Object
   alias Pleroma.Repo
@@ -111,7 +111,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
               Object.decrease_replies_count(in_reply_to)
             end
 
-            ChatMessageReference.delete_for_object(deleted_object)
+            MessageReference.delete_for_object(deleted_object)
 
             ActivityPub.stream_out(object)
             ActivityPub.stream_out_participations(deleted_object, user)
@@ -146,13 +146,13 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
       |> Enum.each(fn [user, other_user] ->
         if user.local do
           {:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
-          {:ok, cm_ref} = ChatMessageReference.create(chat, object, user.ap_id != actor.ap_id)
+          {:ok, cm_ref} = MessageReference.create(chat, object, user.ap_id != actor.ap_id)
 
           # We add a cache of the unread value here so that it
           # doesn't change when being streamed out
           chat =
             chat
-            |> Map.put(:unread, ChatMessageReference.unread_count_for_chat(chat))
+            |> Map.put(:unread, MessageReference.unread_count_for_chat(chat))
 
           Streamer.stream(
             ["user", "user:pleroma_chat"],
index 2ae82eb2d7997540c221d666393c2970f9361cf6..b115786239ab45e5e07583cb46474e2cf90528c9 100644 (file)
@@ -6,7 +6,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
   use Pleroma.Web, :view
 
   alias Pleroma.Activity
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Notification
   alias Pleroma.Object
   alias Pleroma.User
@@ -15,7 +15,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
   alias Pleroma.Web.MastodonAPI.AccountView
   alias Pleroma.Web.MastodonAPI.NotificationView
   alias Pleroma.Web.MastodonAPI.StatusView
-  alias Pleroma.Web.PleromaAPI.ChatMessageReferenceView
+  alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
 
   @parent_types ~w{Like Announce EmojiReact}
 
@@ -139,9 +139,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
     object = Object.normalize(activity)
     author = User.get_cached_by_ap_id(object.data["actor"])
     chat = Pleroma.Chat.get(reading_user.id, author.ap_id)
-    cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+    cm_ref = MessageReference.for_chat_and_object(chat, object)
     render_opts = Map.merge(opts, %{for: reading_user, chat_message_reference: cm_ref})
-    chat_message_render = ChatMessageReferenceView.render("show.json", render_opts)
+    chat_message_render = MessageReferenceView.render("show.json", render_opts)
 
     Map.put(response, :chat_message, chat_message_render)
   end
index 01d47045dfac466e07cce8bcaa919bc610cacaaa..d6b3415d1b3a46ba50696cbb71af26bb35351534 100644 (file)
@@ -6,14 +6,14 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
 
   alias Pleroma.Activity
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Object
   alias Pleroma.Pagination
   alias Pleroma.Plugs.OAuthScopesPlug
   alias Pleroma.Repo
   alias Pleroma.User
   alias Pleroma.Web.CommonAPI
-  alias Pleroma.Web.PleromaAPI.ChatMessageReferenceView
+  alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
   alias Pleroma.Web.PleromaAPI.ChatView
 
   import Ecto.Query
@@ -46,13 +46,13 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
         message_id: message_id,
         id: chat_id
       }) do
-    with %ChatMessageReference{} = cm_ref <-
-           ChatMessageReference.get_by_id(message_id),
+    with %MessageReference{} = cm_ref <-
+           MessageReference.get_by_id(message_id),
          ^chat_id <- cm_ref.chat_id |> to_string(),
          %Chat{user_id: ^user_id} <- Chat.get_by_id(chat_id),
          {:ok, _} <- remove_or_delete(cm_ref, user) do
       conn
-      |> put_view(ChatMessageReferenceView)
+      |> put_view(MessageReferenceView)
       |> render("show.json", chat_message_reference: cm_ref)
     else
       _e ->
@@ -71,7 +71,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
 
   defp remove_or_delete(cm_ref, _) do
     cm_ref
-    |> ChatMessageReference.delete()
+    |> MessageReference.delete()
   end
 
   def post_chat_message(
@@ -87,9 +87,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
              media_id: params[:media_id]
            ),
          message <- Object.normalize(activity, false),
-         cm_ref <- ChatMessageReference.for_chat_and_object(chat, message) do
+         cm_ref <- MessageReference.for_chat_and_object(chat, message) do
       conn
-      |> put_view(ChatMessageReferenceView)
+      |> put_view(MessageReferenceView)
       |> render("show.json", for: user, chat_message_reference: cm_ref)
     end
   end
@@ -98,20 +98,20 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
         id: chat_id,
         message_id: message_id
       }) do
-    with %ChatMessageReference{} = cm_ref <-
-           ChatMessageReference.get_by_id(message_id),
+    with %MessageReference{} = cm_ref <-
+           MessageReference.get_by_id(message_id),
          ^chat_id <- cm_ref.chat_id |> to_string(),
          %Chat{user_id: ^user_id} <- Chat.get_by_id(chat_id),
-         {:ok, cm_ref} <- ChatMessageReference.mark_as_read(cm_ref) do
+         {:ok, cm_ref} <- MessageReference.mark_as_read(cm_ref) do
       conn
-      |> put_view(ChatMessageReferenceView)
+      |> put_view(MessageReferenceView)
       |> render("show.json", for: user, chat_message_reference: cm_ref)
     end
   end
 
   def mark_as_read(%{assigns: %{user: %{id: user_id}}} = conn, %{id: id}) do
     with %Chat{} = chat <- Repo.get_by(Chat, id: id, user_id: user_id),
-         {_n, _} <- ChatMessageReference.set_all_seen_for_chat(chat) do
+         {_n, _} <- MessageReference.set_all_seen_for_chat(chat) do
       conn
       |> put_view(ChatView)
       |> render("show.json", chat: chat)
@@ -122,11 +122,11 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
     with %Chat{} = chat <- Repo.get_by(Chat, id: id, user_id: user_id) do
       cm_refs =
         chat
-        |> ChatMessageReference.for_chat_query()
+        |> MessageReference.for_chat_query()
         |> Pagination.fetch_paginated(params |> stringify_keys())
 
       conn
-      |> put_view(ChatMessageReferenceView)
+      |> put_view(MessageReferenceView)
       |> render("index.json", for: user, chat_message_references: cm_refs)
     else
       _ ->
similarity index 95%
rename from lib/pleroma/web/pleroma_api/views/chat_message_reference_view.ex
rename to lib/pleroma/web/pleroma_api/views/chat/message_reference_view.ex
index 592bb17f0517ee1ab4413d029761084bc1926d60..f2112a86ed5fbd8f5dcaabd44bb17e726c94e1f7 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceView do
+defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
   use Pleroma.Web, :view
 
   alias Pleroma.User
index 91d50dd1e4e94984097cd1c9e2a705a898e9e91b..d4c10977f31d3a608ddda95c668fa74065a9d311 100644 (file)
@@ -6,24 +6,24 @@ defmodule Pleroma.Web.PleromaAPI.ChatView do
   use Pleroma.Web, :view
 
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.User
   alias Pleroma.Web.CommonAPI.Utils
   alias Pleroma.Web.MastodonAPI.AccountView
-  alias Pleroma.Web.PleromaAPI.ChatMessageReferenceView
+  alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
 
   def render("show.json", %{chat: %Chat{} = chat} = opts) do
     recipient = User.get_cached_by_ap_id(chat.recipient)
 
-    last_message = opts[:last_message] || ChatMessageReference.last_message_for_chat(chat)
+    last_message = opts[:last_message] || MessageReference.last_message_for_chat(chat)
 
     %{
       id: chat.id |> to_string(),
       account: AccountView.render("show.json", Map.put(opts, :user, recipient)),
-      unread: Map.get(chat, :unread) || ChatMessageReference.unread_count_for_chat(chat),
+      unread: Map.get(chat, :unread) || MessageReference.unread_count_for_chat(chat),
       last_message:
         last_message &&
-          ChatMessageReferenceView.render("show.json", chat_message_reference: last_message),
+          MessageReferenceView.render("show.json", chat_message_reference: last_message),
       updated_at: Utils.to_masto_date(chat.updated_at)
     }
   end
index b22297955f084931875268eba9c568bf5b2fe61e..d1d2c9b9c5f85bfa53bd48168a5796a8523c80b1 100644 (file)
@@ -6,7 +6,7 @@ defmodule Pleroma.Web.Streamer do
   require Logger
 
   alias Pleroma.Activity
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Config
   alias Pleroma.Conversation.Participation
   alias Pleroma.Notification
@@ -187,7 +187,7 @@ defmodule Pleroma.Web.Streamer do
     end)
   end
 
-  defp do_stream(topic, {user, %ChatMessageReference{} = cm_ref})
+  defp do_stream(topic, {user, %MessageReference{} = cm_ref})
        when topic in ["user", "user:pleroma_chat"] do
     topic = "#{topic}:#{user.id}"
 
similarity index 82%
rename from test/chat_message_reference_test.exs
rename to test/chat/message_reference_test.exs
index 66bf493b40cfa95a44d851477da92f0e9ddebae2..aaa7c1ad4b876eab992d9f1762c29649bf0243d9 100644 (file)
@@ -2,11 +2,11 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.ChatMessageReferenceTest do
+defmodule Pleroma.Chat.MessageReferenceTest do
   use Pleroma.DataCase, async: true
 
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Web.CommonAPI
 
   import Pleroma.Factory
@@ -21,7 +21,7 @@ defmodule Pleroma.ChatMessageReferenceTest do
 
       {:ok, chat} = Chat.get_or_create(user.id, recipient.ap_id)
 
-      message = ChatMessageReference.last_message_for_chat(chat)
+      message = MessageReference.last_message_for_chat(chat)
 
       assert message.object.data["content"] == "ho"
     end
index 43ffe13375a98f69cdbbcfd679d5b9fd963fbc2f..b1afa6a2e976da771436ee7e933acc4e51f9f407 100644 (file)
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
 
   alias Pleroma.Activity
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Notification
   alias Pleroma.Object
   alias Pleroma.Repo
@@ -391,7 +391,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
       end
     end
 
-    test "it creates a Chat and ChatMessageReferences for the local users and bumps the unread count, except for the author" do
+    test "it creates a Chat and MessageReferences for the local users and bumps the unread count, except for the author" do
       author = insert(:user, local: true)
       recipient = insert(:user, local: true)
 
@@ -431,14 +431,14 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
 
         chat = Chat.get(author.id, recipient.ap_id)
 
-        [cm_ref] = ChatMessageReference.for_chat_query(chat) |> Repo.all()
+        [cm_ref] = MessageReference.for_chat_query(chat) |> Repo.all()
 
         assert cm_ref.object.data["content"] == "hey"
         assert cm_ref.unread == false
 
         chat = Chat.get(recipient.id, author.ap_id)
 
-        [cm_ref] = ChatMessageReference.for_chat_query(chat) |> Repo.all()
+        [cm_ref] = MessageReference.for_chat_query(chat) |> Repo.all()
 
         assert cm_ref.object.data["content"] == "hey"
         assert cm_ref.unread == true
index c5691341a07cc621aa35f241f7d8e3402d6aa728..b2fa5b30268a032c95ad5b8178b848c4587e68b8 100644 (file)
@@ -7,7 +7,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
 
   alias Pleroma.Activity
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Notification
   alias Pleroma.Object
   alias Pleroma.Repo
@@ -17,7 +17,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
   alias Pleroma.Web.MastodonAPI.AccountView
   alias Pleroma.Web.MastodonAPI.NotificationView
   alias Pleroma.Web.MastodonAPI.StatusView
-  alias Pleroma.Web.PleromaAPI.ChatMessageReferenceView
+  alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
   import Pleroma.Factory
 
   defp test_notifications_rendering(notifications, user, expected_result) do
@@ -45,15 +45,14 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
     object = Object.normalize(activity)
     chat = Chat.get(recipient.id, user.ap_id)
 
-    cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+    cm_ref = MessageReference.for_chat_and_object(chat, object)
 
     expected = %{
       id: to_string(notification.id),
       pleroma: %{is_seen: false},
       type: "pleroma:chat_mention",
       account: AccountView.render("show.json", %{user: user, for: recipient}),
-      chat_message:
-        ChatMessageReferenceView.render("show.json", %{chat_message_reference: cm_ref}),
+      chat_message: MessageReferenceView.render("show.json", %{chat_message_reference: cm_ref}),
       created_at: Utils.to_masto_date(notification.inserted_at)
     }
 
index 7af6dec1c26576c0c50975d14bb9f3b5a3739b05..e73e4a32e605f4640dff33c4de2b97a2fe8bc86b 100644 (file)
@@ -5,7 +5,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
   use Pleroma.Web.ConnCase, async: true
 
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Object
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
@@ -23,7 +23,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
       {:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
       {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
       object = Object.normalize(create, false)
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
 
       assert cm_ref.unread == true
 
@@ -34,7 +34,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
 
       assert result["unread"] == false
 
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
 
       assert cm_ref.unread == false
     end
@@ -50,7 +50,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
       {:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
       {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
       object = Object.normalize(create, false)
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
 
       assert cm_ref.unread == true
 
@@ -61,7 +61,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
 
       assert result["unread"] == 0
 
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
 
       assert cm_ref.unread == false
     end
@@ -139,7 +139,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
 
       chat = Chat.get(user.id, recipient.ap_id)
 
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
 
       # Deleting your own message removes the message and the reference
       result =
@@ -149,12 +149,12 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
         |> json_response_and_validate_schema(200)
 
       assert result["id"] == cm_ref.id
-      refute ChatMessageReference.get_by_id(cm_ref.id)
+      refute MessageReference.get_by_id(cm_ref.id)
       assert %{data: %{"type" => "Tombstone"}} = Object.get_by_id(object.id)
 
       # Deleting other people's messages just removes the reference
       object = Object.normalize(other_message, false)
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
 
       result =
         conn
@@ -163,7 +163,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
         |> json_response_and_validate_schema(200)
 
       assert result["id"] == cm_ref.id
-      refute ChatMessageReference.get_by_id(cm_ref.id)
+      refute MessageReference.get_by_id(cm_ref.id)
       assert Object.get_by_id(object.id)
     end
   end
similarity index 77%
rename from test/web/pleroma_api/views/chat_message_reference_view_test.exs
rename to test/web/pleroma_api/views/chat/message_reference_view_test.exs
index b53bd349071763fd4e64feec5d1fc8751c4d6e6d..e5b165255989c8df26d379052bab9a326ad27af8 100644 (file)
@@ -2,15 +2,15 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
+defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceViewTest do
   use Pleroma.DataCase
 
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Object
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.CommonAPI
-  alias Pleroma.Web.PleromaAPI.ChatMessageReferenceView
+  alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
 
   import Pleroma.Factory
 
@@ -31,9 +31,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
 
     object = Object.normalize(activity)
 
-    cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+    cm_ref = MessageReference.for_chat_and_object(chat, object)
 
-    chat_message = ChatMessageReferenceView.render("show.json", chat_message_reference: cm_ref)
+    chat_message = MessageReferenceView.render("show.json", chat_message_reference: cm_ref)
 
     assert chat_message[:id] == cm_ref.id
     assert chat_message[:content] == "kippis :firefox:"
@@ -47,10 +47,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
 
     object = Object.normalize(activity)
 
-    cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+    cm_ref = MessageReference.for_chat_and_object(chat, object)
 
-    chat_message_two =
-      ChatMessageReferenceView.render("show.json", chat_message_reference: cm_ref)
+    chat_message_two = MessageReferenceView.render("show.json", chat_message_reference: cm_ref)
 
     assert chat_message_two[:id] == cm_ref.id
     assert chat_message_two[:content] == "gkgkgk"
index f77584dd1f7c2a99ff10e555fc001d03476664ad..f7af5d4e024bafddf3da94fcc96857e5e134ae0d 100644 (file)
@@ -6,12 +6,12 @@ defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
   use Pleroma.DataCase
 
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Object
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.CommonAPI.Utils
   alias Pleroma.Web.MastodonAPI.AccountView
-  alias Pleroma.Web.PleromaAPI.ChatMessageReferenceView
+  alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
   alias Pleroma.Web.PleromaAPI.ChatView
 
   import Pleroma.Factory
@@ -55,9 +55,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
 
     represented_chat = ChatView.render("show.json", chat: chat)
 
-    cm_ref = ChatMessageReference.for_chat_and_object(chat, chat_message)
+    cm_ref = MessageReference.for_chat_and_object(chat, chat_message)
 
     assert represented_chat[:last_message] ==
-             ChatMessageReferenceView.render("show.json", chat_message_reference: cm_ref)
+             MessageReferenceView.render("show.json", chat_message_reference: cm_ref)
   end
 end
index 893ae5449e9149ed932702c517670930d4e9a398..245f6e63f53f7bccab9782c236cea453ecf0f943 100644 (file)
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.StreamerTest do
   import Pleroma.Factory
 
   alias Pleroma.Chat
-  alias Pleroma.ChatMessageReference
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Conversation.Participation
   alias Pleroma.List
   alias Pleroma.Object
@@ -155,7 +155,7 @@ defmodule Pleroma.Web.StreamerTest do
       {:ok, create_activity} = CommonAPI.post_chat_message(other_user, user, "hey cirno")
       object = Object.normalize(create_activity, false)
       chat = Chat.get(user.id, other_user.ap_id)
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
       cm_ref = %{cm_ref | chat: chat, object: object}
 
       Streamer.get_topic_and_add_socket("user:pleroma_chat", user)
@@ -173,7 +173,7 @@ defmodule Pleroma.Web.StreamerTest do
       {:ok, create_activity} = CommonAPI.post_chat_message(other_user, user, "hey cirno")
       object = Object.normalize(create_activity, false)
       chat = Chat.get(user.id, other_user.ap_id)
-      cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
+      cm_ref = MessageReference.for_chat_and_object(chat, object)
       cm_ref = %{cm_ref | chat: chat, object: object}
 
       Streamer.get_topic_and_add_socket("user", user)