PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | app/Http/Controllers/NotificationsController.php +15 -11 1.0.902.10.01 View file →
@@ -14,9 +14,9 @@
14 14 public function getNotifications(Request $request)
15 15 {
16 16 $user = $this->getUser(true);
17 17
18 - $notifcations = Notification::whereHas('subscribers', function ($query) use ($user) {
18 + $notifications = Notification::whereHas('subscribers', function ($query) use ($user) {
19 19 return $query->where('user_id', $user->ID);
20 20 })
21 21 ->with([
22 22 'xprofile' => function ($q) {
@@ -30,11 +30,13 @@
30 30 ->byType($request->get('notification_type', 'all'))
31 31 ->orderBy('updated_at', 'DESC')
32 32 ->paginate();
33 33
34 - return [
35 - 'notifications' => $notifcations
34 + $data = [
35 + 'notifications' => $notifications,
36 + 'unread_count' => Notification::byStatus('unread', $user->ID)->count()
36 37 ];
38 + return apply_filters('fluent_community/notifications_api_response', $data, $request->all());
37 39 }
38 40
39 41 public function getUnreadNotifications(Request $request)
40 42 {
@@ -48,12 +50,14 @@
48 50 ->byType($request->get('notification_type', 'all'))
49 51 ->limit(50)
50 52 ->get();
51 53
52 - return [
54 + $data = [
53 55 'notifications' => $unreadNotifications,
54 56 'unread_count' => Notification::byStatus('unread', get_current_user_id())->count()
55 57 ];
58 +
59 + return apply_filters('fluent_community/unread_notifications_api_response', $data, $request->all());
56 60 }
57 61
58 62 public function markAllRead(Request $request)
59 63 {
@@ -61,19 +65,21 @@
61 65 ->where('user_id', get_current_user_id())
62 66 ->update(['is_read' => 1]);
63 67
64 68 return [
65 - 'message' => __('All notifications has been marked as read.', 'fluent-community')
69 + 'message' => __('All notifications have been marked as read.', 'fluent-community')
66 70 ];
67 71 }
68 72
69 73 public function markAsRead(Request $request, $notification_id)
70 74 {
71 - $notification = Notification::find($notification_id);
75 + $notification = Notification::findOrFail($notification_id);
72 76
73 77 NotificationSubscriber::whereHas('notification', function ($query) use ($notification) {
74 - return $query->where('id', $notification->id)
75 - ->orWhere('feed_id', $notification->feed_id);
78 + $query->where('id', $notification->id);
79 + if ($notification->feed_id) {
80 + $query->orWhere('feed_id', $notification->feed_id);
81 + }
76 82 })
77 83 ->where('user_id', get_current_user_id())
78 84 ->update(['is_read' => 1]);
79 85
@@ -79,15 +85,13 @@
79 85
80 86 return [
81 87 'unread_count' => Notification::byStatus('unread', get_current_user_id())->count()
82 88 ];
83 -
84 - return $this->getUnreadNotifications($request);
85 89 }
86 90
87 91 public function markAsReadByFeedId(Request $request, $feedId)
88 92 {
89 - $feed = Feed::findOrfail($feedId);
93 + $feed = Feed::withoutGlobalScopes()->findOrFail($feedId);
90 94
91 95 NotificationSubscriber::whereHas('notification', function ($query) use ($feed) {
92 96 return $query->where('feed_id', $feed->id);
93 97 })