0e2635aad482b6bbf978b8eac5591c5e0762720e
[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 does not create 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, notifications} = Notification.create_notifications(status)
43
44 assert notifications == []
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 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, notifications} = Notification.create_notifications(status)
201
202 assert notifications == []
203 end
204
205 test "it doesn't create subscription notifications if the recipient cannot see the status" do
206 user = insert(:user)
207 subscriber = insert(:user)
208
209 User.subscribe(subscriber, user)
210
211 {:ok, status} = CommonAPI.post(user, %{"status" => "inwisible", "visibility" => "direct"})
212
213 assert {:ok, []} == Notification.create_notifications(status)
214 end
215 end
216
217 describe "get notification" do
218 test "it gets a notification that belongs to the user" do
219 user = insert(:user)
220 other_user = insert(:user)
221
222 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
223
224 {:ok, [notification]} = Notification.create_notifications(activity)
225 {:ok, notification} = Notification.get(other_user, notification.id)
226
227 assert notification.user_id == other_user.id
228 end
229
230 test "it returns error if the notification doesn't belong to the user" do
231 user = insert(:user)
232 other_user = insert(:user)
233
234 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
235
236 {:ok, [notification]} = Notification.create_notifications(activity)
237 {:error, _notification} = Notification.get(user, notification.id)
238 end
239 end
240
241 describe "dismiss notification" do
242 test "it dismisses a notification that belongs to the user" do
243 user = insert(:user)
244 other_user = insert(:user)
245
246 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
247
248 {:ok, [notification]} = Notification.create_notifications(activity)
249 {:ok, notification} = Notification.dismiss(other_user, notification.id)
250
251 assert notification.user_id == other_user.id
252 end
253
254 test "it returns error if the notification doesn't belong to the user" do
255 user = insert(:user)
256 other_user = insert(:user)
257
258 {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
259
260 {:ok, [notification]} = Notification.create_notifications(activity)
261 {:error, _notification} = Notification.dismiss(user, notification.id)
262 end
263 end
264
265 describe "clear notification" do
266 test "it clears all notifications belonging to the user" do
267 user = insert(:user)
268 other_user = insert(:user)
269 third_user = insert(:user)
270
271 {:ok, activity} =
272 CommonAPI.post(user, %{
273 "status" => "hey @#{other_user.nickname} and @#{third_user.nickname} !"
274 })
275
276 {:ok, _notifs} = Notification.create_notifications(activity)
277
278 {:ok, activity} =
279 CommonAPI.post(user, %{
280 "status" => "hey again @#{other_user.nickname} and @#{third_user.nickname} !"
281 })
282
283 {:ok, _notifs} = Notification.create_notifications(activity)
284 Notification.clear(other_user)
285
286 assert Notification.for_user(other_user) == []
287 assert Notification.for_user(third_user) != []
288 end
289 end
290
291 describe "set_read_up_to()" do
292 test "it sets all notifications as read up to a specified notification ID" do
293 user = insert(:user)
294 other_user = insert(:user)
295
296 {:ok, _activity} =
297 CommonAPI.post(user, %{
298 "status" => "hey @#{other_user.nickname}!"
299 })
300
301 {:ok, _activity} =
302 CommonAPI.post(user, %{
303 "status" => "hey again @#{other_user.nickname}!"
304 })
305
306 [n2, n1] = notifs = Notification.for_user(other_user)
307 assert length(notifs) == 2
308
309 assert n2.id > n1.id
310
311 {:ok, _activity} =
312 CommonAPI.post(user, %{
313 "status" => "hey yet again @#{other_user.nickname}!"
314 })
315
316 Notification.set_read_up_to(other_user, n2.id)
317
318 [n3, n2, n1] = Notification.for_user(other_user)
319
320 assert n1.seen == true
321 assert n2.seen == true
322 assert n3.seen == false
323 end
324 end
325
326 describe "for_user_since/2" do
327 defp days_ago(days) do
328 NaiveDateTime.add(
329 NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second),
330 -days * 60 * 60 * 24,
331 :second
332 )
333 end
334
335 test "Returns recent notifications" do
336 user1 = insert(:user)
337 user2 = insert(:user)
338
339 Enum.each(0..10, fn i ->
340 {:ok, _activity} =
341 CommonAPI.post(user1, %{
342 "status" => "hey ##{i} @#{user2.nickname}!"
343 })
344 end)
345
346 {old, new} = Enum.split(Notification.for_user(user2), 5)
347
348 Enum.each(old, fn notification ->
349 notification
350 |> cast(%{updated_at: days_ago(10)}, [:updated_at])
351 |> Pleroma.Repo.update!()
352 end)
353
354 recent_notifications_ids =
355 user2
356 |> Notification.for_user_since(
357 NaiveDateTime.add(NaiveDateTime.utc_now(), -5 * 86_400, :second)
358 )
359 |> Enum.map(& &1.id)
360
361 Enum.each(old, fn %{id: id} ->
362 refute id in recent_notifications_ids
363 end)
364
365 Enum.each(new, fn %{id: id} ->
366 assert id in recent_notifications_ids
367 end)
368 end
369 end
370
371 describe "notification target determination" do
372 test "it sends notifications to addressed users in new messages" do
373 user = insert(:user)
374 other_user = insert(:user)
375
376 {:ok, activity} =
377 CommonAPI.post(user, %{
378 "status" => "hey @#{other_user.nickname}!"
379 })
380
381 assert other_user in Notification.get_notified_from_activity(activity)
382 end
383
384 test "it sends notifications to mentioned users in new messages" do
385 user = insert(:user)
386 other_user = insert(:user)
387
388 create_activity = %{
389 "@context" => "https://www.w3.org/ns/activitystreams",
390 "type" => "Create",
391 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
392 "actor" => user.ap_id,
393 "object" => %{
394 "type" => "Note",
395 "content" => "message with a Mention tag, but no explicit tagging",
396 "tag" => [
397 %{
398 "type" => "Mention",
399 "href" => other_user.ap_id,
400 "name" => other_user.nickname
401 }
402 ],
403 "attributedTo" => user.ap_id
404 }
405 }
406
407 {:ok, activity} = Transmogrifier.handle_incoming(create_activity)
408
409 assert other_user in Notification.get_notified_from_activity(activity)
410 end
411
412 test "it does not send notifications to users who are only cc in new messages" do
413 user = insert(:user)
414 other_user = insert(:user)
415
416 create_activity = %{
417 "@context" => "https://www.w3.org/ns/activitystreams",
418 "type" => "Create",
419 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
420 "cc" => [other_user.ap_id],
421 "actor" => user.ap_id,
422 "object" => %{
423 "type" => "Note",
424 "content" => "hi everyone",
425 "attributedTo" => user.ap_id
426 }
427 }
428
429 {:ok, activity} = Transmogrifier.handle_incoming(create_activity)
430
431 assert other_user not in Notification.get_notified_from_activity(activity)
432 end
433
434 test "it does not send notification to mentioned users in likes" do
435 user = insert(:user)
436 other_user = insert(:user)
437 third_user = insert(:user)
438
439 {:ok, activity_one} =
440 CommonAPI.post(user, %{
441 "status" => "hey @#{other_user.nickname}!"
442 })
443
444 {:ok, activity_two, _} = CommonAPI.favorite(activity_one.id, third_user)
445
446 assert other_user not in Notification.get_notified_from_activity(activity_two)
447 end
448
449 test "it does not send notification to mentioned users in announces" do
450 user = insert(:user)
451 other_user = insert(:user)
452 third_user = insert(:user)
453
454 {:ok, activity_one} =
455 CommonAPI.post(user, %{
456 "status" => "hey @#{other_user.nickname}!"
457 })
458
459 {:ok, activity_two, _} = CommonAPI.repeat(activity_one.id, third_user)
460
461 assert other_user not in Notification.get_notified_from_activity(activity_two)
462 end
463 end
464
465 describe "notification lifecycle" do
466 test "liking an activity results in 1 notification, then 0 if the activity is deleted" do
467 user = insert(:user)
468 other_user = insert(:user)
469
470 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
471
472 assert Enum.empty?(Notification.for_user(user))
473
474 {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
475
476 assert length(Notification.for_user(user)) == 1
477
478 {:ok, _} = CommonAPI.delete(activity.id, user)
479
480 assert Enum.empty?(Notification.for_user(user))
481 end
482
483 test "liking an activity results in 1 notification, then 0 if the activity is unliked" do
484 user = insert(:user)
485 other_user = insert(:user)
486
487 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
488
489 assert Enum.empty?(Notification.for_user(user))
490
491 {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
492
493 assert length(Notification.for_user(user)) == 1
494
495 {:ok, _, _, _} = CommonAPI.unfavorite(activity.id, other_user)
496
497 assert Enum.empty?(Notification.for_user(user))
498 end
499
500 test "repeating an activity results in 1 notification, then 0 if the activity is deleted" do
501 user = insert(:user)
502 other_user = insert(:user)
503
504 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
505
506 assert Enum.empty?(Notification.for_user(user))
507
508 {:ok, _, _} = CommonAPI.repeat(activity.id, other_user)
509
510 assert length(Notification.for_user(user)) == 1
511
512 {:ok, _} = CommonAPI.delete(activity.id, user)
513
514 assert Enum.empty?(Notification.for_user(user))
515 end
516
517 test "repeating an activity results in 1 notification, then 0 if the activity is unrepeated" do
518 user = insert(:user)
519 other_user = insert(:user)
520
521 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
522
523 assert Enum.empty?(Notification.for_user(user))
524
525 {:ok, _, _} = CommonAPI.repeat(activity.id, other_user)
526
527 assert length(Notification.for_user(user)) == 1
528
529 {:ok, _, _} = CommonAPI.unrepeat(activity.id, other_user)
530
531 assert Enum.empty?(Notification.for_user(user))
532 end
533
534 test "liking an activity which is already deleted does not generate a notification" do
535 user = insert(:user)
536 other_user = insert(:user)
537
538 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
539
540 assert Enum.empty?(Notification.for_user(user))
541
542 {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
543
544 assert Enum.empty?(Notification.for_user(user))
545
546 {:error, _} = CommonAPI.favorite(activity.id, other_user)
547
548 assert Enum.empty?(Notification.for_user(user))
549 end
550
551 test "repeating an activity which is already deleted does not generate a notification" do
552 user = insert(:user)
553 other_user = insert(:user)
554
555 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
556
557 assert Enum.empty?(Notification.for_user(user))
558
559 {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
560
561 assert Enum.empty?(Notification.for_user(user))
562
563 {:error, _} = CommonAPI.repeat(activity.id, other_user)
564
565 assert Enum.empty?(Notification.for_user(user))
566 end
567
568 test "replying to a deleted post without tagging does not generate a notification" do
569 user = insert(:user)
570 other_user = insert(:user)
571
572 {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
573 {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
574
575 {:ok, _reply_activity} =
576 CommonAPI.post(other_user, %{
577 "status" => "test reply",
578 "in_reply_to_status_id" => activity.id
579 })
580
581 assert Enum.empty?(Notification.for_user(user))
582 end
583
584 test "notifications are deleted if a local user is deleted" do
585 user = insert(:user)
586 other_user = insert(:user)
587
588 {:ok, _activity} =
589 CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}", "visibility" => "direct"})
590
591 refute Enum.empty?(Notification.for_user(other_user))
592
593 User.delete(user)
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
639 assert Enum.empty?(Notification.for_user(local_user))
640 end
641 end
642
643 describe "for_user" do
644 test "it returns notifications for muted user without notifications" do
645 user = insert(:user)
646 muted = insert(:user)
647 {:ok, user} = User.mute(user, muted, false)
648
649 {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
650
651 assert length(Notification.for_user(user)) == 1
652 end
653
654 test "it doesn't return notifications for muted user with notifications" do
655 user = insert(:user)
656 muted = insert(:user)
657 {:ok, user} = User.mute(user, muted)
658
659 {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
660
661 assert Notification.for_user(user) == []
662 end
663
664 test "it doesn't return notifications for blocked user" do
665 user = insert(:user)
666 blocked = insert(:user)
667 {:ok, user} = User.block(user, blocked)
668
669 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
670
671 assert Notification.for_user(user) == []
672 end
673
674 test "it doesn't return notificatitons for blocked domain" do
675 user = insert(:user)
676 blocked = insert(:user, ap_id: "http://some-domain.com")
677 {:ok, user} = User.block_domain(user, "some-domain.com")
678
679 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
680
681 assert Notification.for_user(user) == []
682 end
683
684 test "it doesn't return notifications for muted thread" do
685 user = insert(:user)
686 another_user = insert(:user)
687
688 {:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
689
690 {:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
691 assert Notification.for_user(user) == []
692 end
693
694 test "it returns notifications for muted user with notifications and with_muted parameter" do
695 user = insert(:user)
696 muted = insert(:user)
697 {:ok, user} = User.mute(user, muted)
698
699 {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
700
701 assert length(Notification.for_user(user, %{with_muted: true})) == 1
702 end
703
704 test "it returns notifications for blocked user and with_muted parameter" do
705 user = insert(:user)
706 blocked = insert(:user)
707 {:ok, user} = User.block(user, blocked)
708
709 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
710
711 assert length(Notification.for_user(user, %{with_muted: true})) == 1
712 end
713
714 test "it returns notificatitons for blocked domain and with_muted parameter" do
715 user = insert(:user)
716 blocked = insert(:user, ap_id: "http://some-domain.com")
717 {:ok, user} = User.block_domain(user, "some-domain.com")
718
719 {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
720
721 assert length(Notification.for_user(user, %{with_muted: true})) == 1
722 end
723
724 test "it returns notifications for muted thread with_muted parameter" do
725 user = insert(:user)
726 another_user = insert(:user)
727
728 {:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
729
730 {:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
731 assert length(Notification.for_user(user, %{with_muted: true})) == 1
732 end
733 end
734 end