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