| @@ -18,8 +18,9 @@ | ||
| 18 | 18 | use FluentCommunity\App\Models\Feed; |
| 19 | 19 | use FluentCommunity\App\Models\BaseSpace; |
| 20 | 20 | use FluentCommunity\App\Models\XProfile; |
| 21 | 21 | use FluentCommunity\Framework\Support\Arr; |
| 22 | +use FluentCommunity\Modules\PushNotification\PushNotificationModule; | |
| 22 | 23 | |
| 23 | 24 | class FeedsController extends Controller |
| 24 | 25 | { |
| 25 | 26 | public function get(Request $request) |
| @@ -724,11 +725,12 @@ | ||
| 724 | 725 | |
| 725 | 726 | if (isset($data['is_sticky'])) { |
| 726 | 727 | $data['is_sticky'] = $data['is_sticky'] ? 1 : 0; |
| 727 | 728 | if ($data['is_sticky'] && $feed->space_id) { |
| 728 | - // remove all the sticky posts from the space | |
| 729 | + // toBase() keeps the type scope but skips the Orm update()'s updated_at stamp, which would bump the post being un-stuck. | |
| 729 | 730 | Feed::where('space_id', $feed->space_id) |
| 730 | 731 | ->where('is_sticky', 1) |
| 732 | + ->toBase() | |
| 731 | 733 | ->update(['is_sticky' => 0]); |
| 732 | 734 | } |
| 733 | 735 | } |
| 734 | 736 | |
| @@ -741,8 +743,13 @@ | ||
| 741 | 743 | if ($data) { |
| 742 | 744 | $feed->fill($data); |
| 743 | 745 | $dirty = $feed->getDirty(); |
| 744 | 746 | if ($dirty) { |
| 747 | + // Only a real list/unlist transition is activity, so read $dirty, not the request. | |
| 748 | + if (!array_key_exists('status', $dirty)) { | |
| 749 | + $feed->timestamps = false; | |
| 750 | + } | |
| 751 | + | |
| 745 | 752 | $feed->save(); |
| 746 | 753 | do_action('fluent_community/feed/updated', $feed, $dirty); |
| 747 | 754 | } |
| 748 | 755 | } |
| @@ -1276,11 +1283,35 @@ | ||
| 1276 | 1283 | ->orderBy('fcom_notification_users.updated_at', 'DESC') |
| 1277 | 1284 | ->limit($limit) |
| 1278 | 1285 | ->get(); |
| 1279 | 1286 | |
| 1287 | + $commentIds = []; | |
| 1288 | + foreach ($notifications as $notification) { | |
| 1289 | + if (!in_array($notification->action, PushNotificationModule::PUSHED_ACTIONS, true)) { | |
| 1290 | + continue; | |
| 1291 | + } | |
| 1292 | + | |
| 1293 | + $commentIds[] = (int)$notification->object_id; | |
| 1294 | + $commentIds[] = (int)Arr::get((array)$notification->route, 'query.comment_id'); | |
| 1295 | + } | |
| 1296 | + | |
| 1297 | + $pushedCommentIds = PushNotificationModule::getPushedCommentIds( | |
| 1298 | + $userId, | |
| 1299 | + array_values(array_filter(array_unique($commentIds))) | |
| 1300 | + ); | |
| 1301 | + | |
| 1280 | 1302 | $items = []; |
| 1281 | 1303 | |
| 1282 | 1304 | foreach ($notifications as $notification) { |
| 1305 | + $wasPushed = in_array($notification->action, PushNotificationModule::PUSHED_ACTIONS, true) | |
| 1306 | + && (in_array((int)$notification->object_id, $pushedCommentIds, true) | |
| 1307 | + || in_array((int)Arr::get((array)$notification->route, 'query.comment_id'), $pushedCommentIds, true)); | |
| 1308 | + | |
| 1309 | + // The push already told this member; a toast would say it twice. | |
| 1310 | + if ($wasPushed) { | |
| 1311 | + continue; | |
| 1312 | + } | |
| 1313 | + | |
| 1283 | 1314 | $xprofile = $notification->xprofile; |
| 1284 | 1315 | |
| 1285 | 1316 | $items[] = [ |
| 1286 | 1317 | 'id' => (int)$notification->id, |