diff options
| author | lain <lain@soykaf.club> | 2020-09-17 13:37:25 +0200 |
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-09-17 13:37:25 +0200 |
| commit | 5e3c70afa5c02926a5578628431487e92b2175e9 (patch) | |
| tree | c3356281c7f21a8f6e41230e01b2d413a7f5903c /test/support | |
| parent | e39ff2616b6694f97ab793bc60b5caa7b509f0b1 (diff) | |
| download | pleroma-5e3c70afa5c02926a5578628431487e92b2175e9.tar.gz pleroma-5e3c70afa5c02926a5578628431487e92b2175e9.zip | |
AdminAPI Chat tests: Remove factory.
The factory system doesn't work too well with how the chats are
done. Instead of tempting people to use it, let's rather use the
CommonAPI system for now.
Diffstat (limited to 'test/support')
| -rw-r--r-- | test/support/factory.ex | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index e59d83242..2fdfabbc5 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -441,58 +441,4 @@ defmodule Pleroma.Factory do phrase: "cofe" } end - - def chat_factory(attrs \\ %{}) do - user = attrs[:user] || insert(:user) - recipient = attrs[:recipient] || insert(:user) - - %Pleroma.Chat{ - user_id: user.id, - recipient: recipient.ap_id - } - end - - def chat_message_factory(attrs \\ %{}) do - text = sequence(:text, &"This is :moominmamma: chat message #{&1}") - chat = attrs[:chat] || insert(:chat) - - data = %{ - "type" => "ChatMessage", - "content" => text, - "id" => Pleroma.Web.ActivityPub.Utils.generate_object_id(), - "actor" => User.get_by_id(chat.user_id).ap_id, - "to" => [chat.recipient], - "published" => DateTime.utc_now() |> DateTime.to_iso8601() - } - - %Pleroma.Object{ - data: merge_attributes(data, Map.get(attrs, :data, %{})) - } - end - - def chat_message_activity_factory(attrs \\ %{}) do - chat = attrs[:chat] || insert(:chat) - chat_message = attrs[:chat_message] || insert(:chat_message, chat: chat) - - data_attrs = attrs[:data_attrs] || %{} - attrs = Map.drop(attrs, [:chat, :chat_message, :data_attrs]) - - data = - %{ - "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), - "type" => "Create", - "actor" => chat_message.data["actor"], - "to" => chat_message.data["to"], - "object" => chat_message.data["id"], - "published" => DateTime.utc_now() |> DateTime.to_iso8601() - } - |> Map.merge(data_attrs) - - %Pleroma.Activity{ - data: data, - actor: data["actor"], - recipients: data["to"] - } - |> Map.merge(attrs) - end end |
