Merge branch 'dont-stream-chatmessages' into 'develop'

SideEffects: don't stream Create/ChatMessage in an 'update' event

See merge request soapbox-pub/soapbox-be!105
This commit is contained in:
Alex Gleason 2022-02-28 21:20:55 +00:00
commit 01a6b1aab9
2 changed files with 14 additions and 1 deletions

View file

@ -226,7 +226,11 @@ def handle(%{data: %{"type" => "Create"}} = activity, meta) do
meta
|> add_notifications(notifications)
ap_streamer().stream_out(activity)
# ChatMessages are special, as they get streamed in handle_object_creation/3
# TODO: maybe whitelist allowed object types to stream?
if object.data["type"] != "ChatMessage" do
ap_streamer().stream_out(activity)
end
{:ok, activity, meta}
else

View file

@ -298,6 +298,15 @@ test "it sends chat messages to the 'user' stream", %{user: user, token: oauth_t
assert_receive {:text, ^text}
end
test "it does not send 'update' events for chat messages", %{user: user, token: oauth_token} do
other_user = insert(:user)
Streamer.get_topic_and_add_socket("user", user, oauth_token)
{:ok, activity} = CommonAPI.post_chat_message(other_user, user, "hey")
refute_receive {:render_with_user, _, _, ^activity}
end
test "it sends chat message notifications to the 'user:notification' stream", %{
user: user,
token: oauth_token