[#1149] Merge remote-tracking branch 'remotes/upstream/develop' into 1149-oban-job...
[akkoma] / test / notification_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.NotificationTest do
6 use Pleroma.DataCase
7
8 import Pleroma.Factory
9
10 alias Pleroma.Notification
11 alias Pleroma.Tests.ObanHelpers
12 alias Pleroma.User
13 alias Pleroma.Web.ActivityPub.Transmogrifier
14 alias Pleroma.Web.CommonAPI
15 alias Pleroma.Web.Streamer
16
17 describe "create_notifications" do
18 test "notifies someone when they are directly addressed" do
19 user = insert(:user)
20 other_user = insert(:user)
21 third_user = insert(:user)
22
23 {:ok, activity} =
24 CommonAPI.post(user, %{
25 "status" => "hey @#{other_user.nickname} and @#{third_user.nickname}"
26 })
27
28 {:ok, [notification, other_notification]} = Notification.create_notifications(activity)
29
30 notified_ids = Enum.sort([notification.user_id, other_notification.user_id])
31 assert notified_ids == [other_user.id, third_user.id]
32 assert notification.activity_id == activity.id
33 assert other_notification.activity_id == activity.id
34 end
35
36 test "it creates a notification for subscribed users" do
37 user = insert(:user)
38 subscriber = insert(:user)
39
40 User.subscribe(subscriber, user)
41
42 {:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
43 {:ok, [notification]} = Notification.create_notifications(status)
44
45 assert notification.user_id == subscriber.id
46 end
47
48 test "does not create a notification for subscribed users if status is a reply" do
49 user = insert(:user)
50 other_user = insert(:user)
51 subscriber = insert(:user)
52
53 User.subscribe(subscriber, other_user)
54
55 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
56
57 {:ok, _reply_activity} =
58 CommonAPI.post(other_user, %{
59 "status" => "test reply",
60 "in_reply_to_status_id" => activity.id
61 })
62
63 user_notifications = Notification.for_user(user)
64 assert length(user_notifications) == 1
65
66 subscriber_notifications = Notification.for_user(subscriber)
67 assert Enum.empty?(subscriber_notifications)
68 end
69 end
70
71 describe "create_notification" do
72 setup do
73 GenServer.start(Streamer, %{}, name: Streamer)
74
75 on_exit(fn ->
76 if pid = Process.whereis(Streamer) do
77 Process.exit(pid, :kill)
78 end
79 end)
80 end
81
82 test "it creates a notification for user and send to the 'user' and the 'user:notification' stream" do
83 user = insert(:user)
84 task = Task.async(fn -> assert_receive {:text, _}, 4_000 end)
85 task_user_notification = Task.async(fn -> assert_receive {:text, _}, 4_000 end)
86 Streamer.add_socket("user", %{transport_pid: task.pid, assigns: %{user: user}})
87
88 Streamer.add_socket(
89 "user:notification",
90 %{transport_pid: task_user_notification.pid, assigns: %{user: user}}
91 )
92
93 activity = insert(:note_activity)
94
95 notify = Notification.create_notification(activity, user)
96 assert notify.user_id == user.id
97 Task.await(task)
98 Task.await(task_user_notification)
99 end
100
101 test "it creates a notification for user if the user blocks the activity author" do
102 activity = insert(:note_activity)
103 author = User.get_cached_by_ap_id(activity.data["actor"])
104 user = insert(:user)
105 {:ok, user} = User.block(user, author)
106
107 assert Notification.create_notification(activity, user)
108 end
109
110 test "it creates a notificatin for the user if the user mutes the activity author" do
111 muter = insert(:user)
112 muted = insert(:user)
113 {:ok, _} = User.mute(muter, muted)
114 muter = Repo.get(User, muter.id)
115 {:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"})
116
117 assert Notification.create_notification(activity, muter)
118 end
119
120 test "notification created if user is muted without notifications" do
121 muter = insert(:user)
122 muted = insert(:user)
123
124 {:ok, muter} = User.mute(muter, muted, false)
125
126 {:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"})
127
128 assert Notification.create_notification(activity, muter)
129 end
130
131 test "it creates a notification for an activity from a muted thread" do
132 muter = insert(:user)
133 other_user = insert(:user)
134 {:ok, activity} = CommonAPI.post(muter, %{"status" => "hey"})
135 CommonAPI.add_mute(muter, activity)
136
137 {:ok, activity} =
138 CommonAPI.post(other_user, %{
139 "status" => "Hi @#{muter.nickname}",
140 "in_reply_to_status_id" => activity.id
141 })
142
143 assert Notification.create_notification(activity, muter)
144 end
145
146 test "it disables notifications from followers" do
147 follower = insert(:user)
148 followed = insert(:user, info: %{notification_settings: %{"followers" => false}})
149 User.follow(follower, followed)
150 {:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
151 refute Notification.create_notification(activity, followed)
152 end
153
154 test "it disables notifications from non-followers" do
155 follower = insert(:user)
156 followed = insert(:user, info: %{notification_settings: %{"non_followers" => false}})
157 {:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
158 refute Notification.create_notification(activity, followed)
159 end
160
161 test "it disables notifications from people the user follows" do
162 follower = insert(:user, info: %{notification_settings: %{"follows" => false}})
163 followed = insert(:user)
164 User.follow(follower, followed)
165 follower = Repo.get(User, follower.id)
166 {:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
167 refute Notification.create_notification(activity, follower)
168 end
169
170 test "it disables notifications from people the user does not follow" do
171 follower = insert(:user, info: %{notification_settings: %{"non_follows" => false}})
172 followed = insert(:user)
173 {:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
174 refute Notification.create_notification(activity, follower)
175 end
176
177 test "it doesn't create a notification for user if he is the activity author" do
178 activity = insert(:note_activity)
179 author = User.get_cached_by_ap_id(activity.data["actor"])
180
181 refute Notification.create_notification(activity, author)
182 end
183
184 test "it doesn't create a notification for follow-unfollow-follow chains" do
185 user = insert(:user)
186 followed_user = insert(:user)
187 {:ok, _, _, activity} = CommonAPI.follow(user, followed_user)
188 Notification.create_notification(activity, followed_user)
189 CommonAPI.unfollow(user, followed_user)
190 {:ok, _, _, activity_dupe} = CommonAPI.follow(user, followed_user)
191 refute Notification.create_notification(activity_dupe, followed_user)
192 end
193
194 test "it doesn't create duplicate notifications for follow+subscribed users" do
195 user = insert(:user)
196 subscriber = insert(:user)
197
198 {:ok, _, _, _} = CommonAPI.follow(subscriber, user)
199 User.subscribe(subscriber, user)
200 {:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
201 {:ok, [_notif]} = Notification.create_notifications(status)
202 end
203
204 test "it doesn't create subscription notifications if the recipient cannot see the status" do
205 user = insert(:user)
206 subscriber = insert(:user)
207
208 User.subscribe(subscriber, user)
209
210 {:ok, status} = CommonAPI.post(user, %{"status" => "inwisible", "visibility" => "direct"})
211
212 assert {:ok, []} == Notification.create_notifications(status)
213 end
214 end
215
216 describe "get notification" do
217 test "it gets a notification that belongs to the user" do
218 user = insert(:user)
219 other_user = insert(:user)
220
221 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
222
223 {:ok, [notification]} = Notification.create_notifications(activity)
224 {:ok, notification} = Notification.get(other_user, notification.id)
225
226 assert notification.user_id == other_user.id
227 end
228
229 test "it returns error if the notification doesn't belong to the user" do
230 user = insert(:user)
231 other_user = insert(:user)
232
233 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
234
235 {:ok, [notification]} = Notification.create_notifications(activity)
236 {:error, _notification} = Notification.get(user, notification.id)
237 end
238 end
239
240 describe "dismiss notification" do
241 test "it dismisses a notification that belongs to the user" do
242 user = insert(:user)
243 other_user = insert(:user)
244
245 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
246
247 {:ok, [notification]} = Notification.create_notifications(activity)
248 {:ok, notification} = Notification.dismiss(other_user, notification.id)
249
250 assert notification.user_id == other_user.id
251 end
252
253 test "it returns error if the notification doesn't belong to the user" do
254 user = insert(:user)
255 other_user = insert(:user)
256
257 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
258
259 {:ok, [notification]} = Notification.create_notifications(activity)
260 {:error, _notification} = Notification.dismiss(user, notification.id)
261 end
262 end
263
264 describe "clear notification" do
265 test "it clears all notifications belonging to the user" do
266 user = insert(:user)
267 other_user = insert(:user)
268 third_user = insert(:user)
269
270 {:ok, activity} =
271 CommonAPI.post(user, %{
272 "status" => "hey @#{other_user.nickname} and @#{third_user.nickname} !"
273 })
274
275 {:ok, _notifs} = Notification.create_notifications(activity)
276
277 {:ok, activity} =
278 CommonAPI.post(user, %{
279 "status" => "hey again @#{other_user.nickname} and @#{third_user.nickname} !"
280 })
281
282 {:ok, _notifs} = Notification.create_notifications(activity)
283 Notification.clear(other_user)
284
285 assert Notification.for_user(other_user) == []
286 assert Notification.for_user(third_user) != []
287 end
288 end
289
290 describe "set_read_up_to()" do
291 test "it sets all notifications as read up to a specified notification ID" do
292 user = insert(:user)
293 other_user = insert(:user)
294
295 {:ok, _activity} =
296 CommonAPI.post(user, %{
297 "status" => "hey @#{other_user.nickname}!"
298 })
299
300 {:ok, _activity} =
301 CommonAPI.post(user, %{
302 "status" => "hey again @#{other_user.nickname}!"
303 })
304
305 [n2, n1] = notifs = Notification.for_user(other_user)
306 assert length(notifs) == 2
307
308 assert n2.id > n1.id
309
310 {:ok, _activity} =
311 CommonAPI.post(user, %{
312 "status" => "hey yet again @#{other_user.nickname}!"
313 })
314
315 Notification.set_read_up_to(other_user, n2.id)
316
317 [n3, n2, n1] = Notification.for_user(other_user)
318
319 assert n1.seen == true
320 assert n2.seen == true
321 assert n3.seen == false
322 end
323 end
324
325 describe "for_user_since/2" do
326 defp days_ago(days) do
327 NaiveDateTime.add(
328 NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second),
329 -days * 60 * 60 * 24,
330 :second
331 )
332 end
333
334 test "Returns recent notifications" do
335 user1 = insert(:user)
336 user2 = insert(:user)
337
338 Enum.each(0..10, fn i ->
339 {:ok, _activity} =
340 CommonAPI.post(user1, %{
341 "status" => "hey ##{i} @#{user2.nickname}!"
342 })
343 end)
344
345 {old, new} = Enum.split(Notification.for_user(user2), 5)
346
347 Enum.each(old, fn notification ->
348 notification
349 |> cast(%{updated_at: days_ago(10)}, [:updated_at])
350 |> Pleroma.Repo.update!()
351 end)
352
353 recent_notifications_ids =
354 user2
355 |> Notification.for_user_since(
356 NaiveDateTime.add(NaiveDateTime.utc_now(), -5 * 86_400, :second)
357 )
358 |> Enum.map(& &1.id)
359
360 Enum.each(old, fn %{id: id} ->
361 refute id in recent_notifications_ids
362 end)
363
364 Enum.each(new, fn %{id: id} ->
365 assert id in recent_notifications_ids
366 end)
367 end
368 end
369
370 describe "notification target determination" do
371 test "it sends notifications to addressed users in new messages" do
372 user = insert(:user)
373 other_user = insert(:user)
374
375 {:ok, activity} =
376 CommonAPI.post(user, %{
377 "status" => "hey @#{other_user.nickname}!"
378 })
379
380 assert other_user in Notification.get_notified_from_activity(activity)
381 end
382
383 test "it sends notifications to mentioned users in new messages" do
384 user = insert(:user)
385 other_user = insert(:user)
386
387 create_activity = %{
388 "@context" => "https://www.w3.org/ns/activitystreams",
389 "type" => "Create",
390 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
391 "actor" => user.ap_id,
392 "object" => %{
393 "type" => "Note",
394 "content" => "message with a Mention tag, but no explicit tagging",
395 "tag" => [
396 %{
397 "type" => "Mention",
398 "href" => other_user.ap_id,
399 "name" => other_user.nickname
400 }
401 ],
402 "attributedTo" => user.ap_id
403 }
404 }
405
406 {:ok, activity} = Transmogrifier.handle_incoming(create_activity)
407
408 assert other_user in Notification.get_notified_from_activity(activity)
409 end
410
411 test "it does not send notifications to users who are only cc in new messages" do
412 user = insert(:user)
413 other_user = insert(:user)
414
415 create_activity = %{
416 "@context" => "https://www.w3.org/ns/activitystreams",
417 "type" => "Create",
418 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
419 "cc" => [other_user.ap_id],
420 "actor" => user.ap_id,
421 "object" => %{
422 "type" => "Note",
423 "content" => "hi everyone",
424 "attributedTo" => user.ap_id
425 }
426 }
427
428 {:ok, activity} = Transmogrifier.handle_incoming(create_activity)
429
430 assert other_user not in Notification.get_notified_from_activity(activity)
431 end
432
433 test "it does not send notification to mentioned users in likes" do
434 user = insert(:user)
435 other_user = insert(:user)
436 third_user = insert(:user)
437
438 {:ok, activity_one} =
439 CommonAPI.post(user, %{
440 "status" => "hey @#{other_user.nickname}!"
441 })
442
443 {:ok, activity_two, _} = CommonAPI.favorite(activity_one.id, third_user)
444
445 assert other_user not in Notification.get_notified_from_activity(activity_two)
446 end
447
448 test "it does not send notification to mentioned users in announces" do
449 user = insert(:user)
450 other_user = insert(:user)
451 third_user = insert(:user)
452
453 {:ok, activity_one} =
454 CommonAPI.post(user, %{
455 "status" => "hey @#{other_user.nickname}!"
456 })
457
458 {:ok, activity_two, _} = CommonAPI.repeat(activity_one.id, third_user)
459
460 assert other_user not in Notification.get_notified_from_activity(activity_two)
461 end
462 end
463
464 describe "notification lifecycle" do
465 test "liking an activity results in 1 notification, then 0 if the activity is deleted" do
466 user = insert(:user)
467 other_user = insert(:user)
468
469 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
470
471 assert Enum.empty?(Notification.for_user(user))
472
473 {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
474
475 assert length(Notification.for_user(user)) == 1
476
477 {:ok, _} = CommonAPI.delete(activity.id, user)
478
479 assert Enum.empty?(Notification.for_user(user))
480 end
481
482 test "liking an activity results in 1 notification, then 0 if the activity is unliked" do
483 user = insert(:user)
484 other_user = insert(:user)
485
486 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
487
488 assert Enum.empty?(Notification.for_user(user))
489
490 {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
491
492 assert length(Notification.for_user(user)) == 1
493
494 {:ok, _, _, _} = CommonAPI.unfavorite(activity.id, other_user)
495
496 assert Enum.empty?(Notification.for_user(user))
497 end
498
499 test "repeating an activity results in 1 notification, then 0 if the activity is deleted" do
500 user = insert(:user)
501 other_user = insert(:user)
502
503 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
504
505 assert Enum.empty?(Notification.for_user(user))
506
507 {:ok, _, _} = CommonAPI.repeat(activity.id, other_user)
508
509 assert length(Notification.for_user(user)) == 1
510
511 {:ok, _} = CommonAPI.delete(activity.id, user)
512
513 assert Enum.empty?(Notification.for_user(user))
514 end
515
516 test "repeating an activity results in 1 notification, then 0 if the activity is unrepeated" do
517 user = insert(:user)
518 other_user = insert(:user)
519
520 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
521
522 assert Enum.empty?(Notification.for_user(user))
523
524 {:ok, _, _} = CommonAPI.repeat(activity.id, other_user)
525
526 assert length(Notification.for_user(user)) == 1
527
528 {:ok, _, _} = CommonAPI.unrepeat(activity.id, other_user)
529
530 assert Enum.empty?(Notification.for_user(user))
531 end
532
533 test "liking an activity which is already deleted does not generate a notification" do
534 user = insert(:user)
535 other_user = insert(:user)
536
537 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
538
539 assert Enum.empty?(Notification.for_user(user))
540
541 {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
542
543 assert Enum.empty?(Notification.for_user(user))
544
545 {:error, _} = CommonAPI.favorite(activity.id, other_user)
546
547 assert Enum.empty?(Notification.for_user(user))
548 end
549
550 test "repeating an activity which is already deleted does not generate a notification" do
551 user = insert(:user)
552 other_user = insert(:user)
553
554 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
555
556 assert Enum.empty?(Notification.for_user(user))
557
558 {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
559
560 assert Enum.empty?(Notification.for_user(user))
561
562 {:error, _} = CommonAPI.repeat(activity.id, other_user)
563
564 assert Enum.empty?(Notification.for_user(user))
565 end
566
567 test "replying to a deleted post without tagging does not generate a notification" do
568 user = insert(:user)
569 other_user = insert(:user)
570
571 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
572 {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
573
574 {:ok, _reply_activity} =
575 CommonAPI.post(other_user, %{
576 "status" => "test reply",
577 "in_reply_to_status_id" => activity.id
578 })
579
580 assert Enum.empty?(Notification.for_user(user))
581 end
582
583 test "notifications are deleted if a local user is deleted" do
584 user = insert(:user)
585 other_user = insert(:user)
586
587 {:ok, _activity} =
588 CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}", "visibility" => "direct"})
589
590 refute Enum.empty?(Notification.for_user(other_user))
591
592 {:ok, job} = User.delete(user)
593 ObanHelpers.perform(job)
594
595 assert Enum.empty?(Notification.for_user(other_user))
596 end
597
598 test "notifications are deleted if a remote user is deleted" do
599 remote_user = insert(:user)
600 local_user = insert(:user)
601
602 dm_message = %{
603 "@context" => "https://www.w3.org/ns/activitystreams",
604 "type" => "Create",
605 "actor" => remote_user.ap_id,
606 "id" => remote_user.ap_id <> "/activities/test",
607 "to" => [local_user.ap_id],
608 "cc" => [],
609 "object" => %{
610 "type" => "Note",
611 "content" => "Hello!",
612 "tag" => [
613 %{
614 "type" => "Mention",
615 "href" => local_user.ap_id,
616 "name" => "@#{local_user.nickname}"
617 }
618 ],
619 "to" => [local_user.ap_id],
620 "cc" => [],
621 "attributedTo" => remote_user.ap_id
622 }
623 }
624
625 {:ok, _dm_activity} = Transmogrifier.handle_incoming(dm_message)
626
627 refute Enum.empty?(Notification.for_user(local_user))
628
629 delete_user_message = %{
630 "@context" => "https://www.w3.org/ns/activitystreams",
631 "id" => remote_user.ap_id <> "/activities/delete",
632 "actor" => remote_user.ap_id,
633 "type" => "Delete",
634 "object" => remote_user.ap_id
635 }
636
637 {:ok, _delete_activity} = Transmogrifier.handle_incoming(delete_user_message)
638 ObanHelpers.perform_all()
639
640 assert Enum.empty?(Notification.for_user(local_user))
641 end
642 end
643
644 describe "for_user" do
645 test "it returns notifications for muted user without notifications" do
646 user = insert(:user)
647 muted = insert(:user)
648 {:ok, user} = User.mute(user, muted, false)
649
650 {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
651
652 assert length(Notification.for_user(user)) == 1
653 end
654
655 test "it doesn't return notifications for muted user with notifications" do
656 user = insert(:user)
657 muted = insert(:user)
658 {:ok, user} = User.mute(user, muted)
659
660 {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
661
662 assert Notification.for_user(user) == []
663 end
664
665 test "it doesn't return notifications for blocked user" do
666 user = insert(:user)
667 blocked = insert(:user)
668 {:ok, user} = User.block(user, blocked)
669
670 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
671
672 assert Notification.for_user(user) == []
673 end
674
675 test "it doesn't return notificatitons for blocked domain" do
676 user = insert(:user)
677 blocked = insert(:user, ap_id: "http://some-domain.com")
678 {:ok, user} = User.block_domain(user, "some-domain.com")
679
680 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
681
682 assert Notification.for_user(user) == []
683 end
684
685 test "it doesn't return notifications for muted thread" do
686 user = insert(:user)
687 another_user = insert(:user)
688
689 {:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
690
691 {:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
692 assert Notification.for_user(user) == []
693 end
694
695 test "it returns notifications for muted user with notifications and with_muted parameter" do
696 user = insert(:user)
697 muted = insert(:user)
698 {:ok, user} = User.mute(user, muted)
699
700 {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
701
702 assert length(Notification.for_user(user, %{with_muted: true})) == 1
703 end
704
705 test "it returns notifications for blocked user and with_muted parameter" do
706 user = insert(:user)
707 blocked = insert(:user)
708 {:ok, user} = User.block(user, blocked)
709
710 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
711
712 assert length(Notification.for_user(user, %{with_muted: true})) == 1
713 end
714
715 test "it returns notificatitons for blocked domain and with_muted parameter" do
716 user = insert(:user)
717 blocked = insert(:user, ap_id: "http://some-domain.com")
718 {:ok, user} = User.block_domain(user, "some-domain.com")
719
720 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
721
722 assert length(Notification.for_user(user, %{with_muted: true})) == 1
723 end
724
725 test "it returns notifications for muted thread with_muted parameter" do
726 user = insert(:user)
727 another_user = insert(:user)
728
729 {:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
730
731 {:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
732 assert length(Notification.for_user(user, %{with_muted: true})) == 1
733 end
734 end
735 end