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