PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.0 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 All 78 releases
← All changes | app/Hooks/Handlers/EmailNotificationHandler.php +33 -28 2.8.02.11.0 View file →
@@ -60,22 +60,23 @@
60 60 if (!$space) {
61 61 return false;
62 62 }
63 63
64 - $types = ['np_by_member_mail'];
64 + $events = ['np_by_member'];
65 65 $spaceRole = $feed->user->getSpaceRole($feed->space);
66 66 if (in_array($spaceRole, ['admin', 'moderator'])) {
67 - $types[] = 'np_by_admin_mail';
67 + $events[] = 'np_by_admin';
68 68 }
69 69
70 - $hasSubscribers = User::query()->where(function ($query) use ($types, $space, $feed) {
71 - $query->whereHas('notificationSubscriptions', function ($query) use ($types, $space) {
72 - $query->whereIn('notification_type', $types)
70 + $hasSubscribers = User::query()->where(function ($query) use ($events, $space, $feed) {
71 + $query->whereHas('notificationPreferences', function ($query) use ($events, $space) {
72 + $query->where('channel', 'mail')
73 + ->whereIn('event_key', $events)
73 74 ->where('object_id', $space->id)
74 - ->where('is_read', 1);
75 + ->where('value', 1);
75 76 });
76 77
77 - do_action_ref_array('fluent_community/space_feed/email_notify_sub_query', [&$query, $feed, $space, $types]);
78 + do_action_ref_array('fluent_community/space_feed/email_notify_sub_query', [&$query, $feed, $space, $events]);
78 79
79 80 return $query;
80 81 })->exists();
81 82
@@ -107,20 +108,21 @@
107 108 if (!$space || !$feed->user) {
108 109 return;
109 110 }
110 111
111 - $types = ['np_by_member_mail'];
112 + $events = ['np_by_member'];
112 113 $spaceRole = $feed->user->getSpaceRole($feed->space);
113 114 if (in_array($spaceRole, ['admin', 'moderator'])) {
114 - $types[] = 'np_by_admin_mail';
115 + $events[] = 'np_by_admin';
115 116 }
116 117
117 118 $lastSendUserId = (int)$feed->getCustomMeta('_last_email_user_id', 0);
118 - $usersQuery = User::query()->where(function ($query) use ($types, $space, $feed) {
119 - $query->whereHas('notificationSubscriptions', function ($query) use ($types, $space) {
120 - $query->whereIn('notification_type', $types)
119 + $usersQuery = User::query()->where(function ($query) use ($events, $space, $feed) {
120 + $query->whereHas('notificationPreferences', function ($query) use ($events, $space) {
121 + $query->where('channel', 'mail')
122 + ->whereIn('event_key', $events)
121 123 ->where('object_id', $space->id)
122 - ->where('is_read', 1);
124 + ->where('value', 1);
123 125 });
124 126
125 127 $mentionedUserIds = Arr::get($feed->meta, 'mentioned_user_ids', []);
126 128
@@ -127,9 +129,9 @@
127 129 if ($mentionedUserIds) {
128 130 $query->orWhereIn('ID', $mentionedUserIds);
129 131 }
130 132
131 - do_action_ref_array('fluent_community/space_feed/email_notify_sub_query', [&$query, $feed, $space, $types]);
133 + do_action_ref_array('fluent_community/space_feed/email_notify_sub_query', [&$query, $feed, $space, $events]);
132 134
133 135 return $query;
134 136 })
135 137 ->whereHas('space_pivot', function ($query) use ($space) {
@@ -246,9 +248,9 @@
246 248
247 249 $authorId = FeedsHelper::getNotificationAuthorId($feed);
248 250
249 251 $notificationUserIds = [];
250 - if ($comment->user_id != $authorId && NotificationPref::willGetCommentEmail($authorId, $globalCommentStatus)) {
252 + if ($comment->user_id != $authorId && NotificationPref::willGetNotification($authorId, 'comment', 'mail', $globalCommentStatus)) {
251 253 as_schedule_single_action(time(), 'fluent_community/comment_added_async', [$comment->id, 0], 'fluent-community');
252 254 return true;
253 255 }
254 256
@@ -254,9 +256,9 @@
254 256
255 257 if ($comment->parent_id) {
256 258 $notificationUserIds = $comment->getCommentParentUserIds();
257 259 $notificationUserIds = array_filter($notificationUserIds, function ($userId) use ($globalCommentStatus) {
258 - return NotificationPref::willGetCommentReplyEmail($userId, $globalCommentStatus);
260 + return NotificationPref::willGetNotification($userId, 'reply', 'mail', $globalCommentStatus);
259 261 });
260 262 }
261 263
262 264 if (!$notificationUserIds) {
@@ -289,14 +291,14 @@
289 291 }
290 292
291 293 $notificationUserIds = $comment->getCommentParentUserIds($lastUserId);
292 294 $notificationUserIds = array_filter($notificationUserIds, function ($userId) use ($globalCommentStatus) {
293 - return NotificationPref::willGetCommentReplyEmail($userId, $globalCommentStatus);
295 + return NotificationPref::willGetNotification($userId, 'reply', 'mail', $globalCommentStatus);
294 296 });
295 297
296 298 $notificationUserIds = array_diff($notificationUserIds, [$comment->user_id]);
297 299 $authorId = FeedsHelper::getNotificationAuthorId($feed);
298 - if ($comment->user_id != $authorId && NotificationPref::willGetCommentEmail($authorId, $globalCommentStatus)) {
300 + if ($comment->user_id != $authorId && NotificationPref::willGetNotification($authorId, 'comment', 'mail', $globalCommentStatus)) {
299 301 // Add at the first
300 302 $notificationUserIds[] = $authorId;
301 303 }
302 304
@@ -302,9 +304,9 @@
302 304
303 305 // the mentioned user ids
304 306 if ($mentionedUserIds = Arr::get($comment->meta, 'mentioned_user_ids', [])) {
305 307 foreach ($mentionedUserIds as $mentionedUserId) {
306 - if (NotificationPref::willGetMentionEmail($mentionedUserId, $this->isEnabled('mention_mail'))) {
308 + if (NotificationPref::willGetNotification($mentionedUserId, 'mention', 'mail', $this->isEnabled('mention_mail'))) {
307 309 $notificationUserIds[] = $mentionedUserId;
308 310 }
309 311 }
310 312 }
@@ -422,11 +424,12 @@
422 424 if (!$notification) {
423 425 return true;
424 426 }
425 427
426 - $users = User::whereDoesntHave('notificationSubscriptions', function ($query) {
427 - $query->where('notification_type', 'mention_mail')
428 - ->where('is_read', 0);
428 + $users = User::whereDoesntHave('notificationPreferences', function ($query) {
429 + $query->where('channel', 'mail')
430 + ->where('event_key', 'mention')
431 + ->where('value', 0);
429 432 })
430 433 ->whereHas('space_pivot', function ($query) use ($feed) {
431 434 $query->where('space_id', $feed->space_id)
432 435 ->where('status', 'active');
@@ -543,11 +546,12 @@
543 546 $globalEnabled = Arr::get($settings, 'digest_email_status') === 'yes';
544 547 $lastSentUserId = Utility::getOption('last_digest_sent_user_id');
545 548
546 549 if ($globalEnabled) {
547 - $users = User::whereDoesntHave('notification_records', function ($query) {
548 - $query->where('notification_type', 'digest_mail')
549 - ->where('is_read', 0);
550 + $users = User::whereDoesntHave('notificationPreferences', function ($query) {
551 + $query->where('channel', 'mail')
552 + ->where('event_key', 'digest')
553 + ->where('value', 0);
550 554 })
551 555 ->whereHas('xprofile', function ($query) {
552 556 $query->where('status', 'active');
553 557 })
@@ -557,11 +561,12 @@
557 561 ->limit(100)
558 562 ->orderBy('ID', 'ASC')
559 563 ->get();
560 564 } else {
561 - $users = User::whereHas('notification_records', function ($query) {
562 - $query->where('notification_type', 'digest_mail')
563 - ->where('is_read', 1);
565 + $users = User::whereHas('notificationPreferences', function ($query) {
566 + $query->where('channel', 'mail')
567 + ->where('event_key', 'digest')
568 + ->where('value', 1);
564 569 })
565 570 ->whereHas('xprofile', function ($query) {
566 571 $query->where('status', 'active');
567 572 })