| @@ -5,9 +5,8 @@ | ||
| 5 | 5 | use FluentCommunity\App\Functions\Utility; |
| 6 | 6 | use FluentCommunity\App\Models\Media; |
| 7 | 7 | use FluentCommunity\App\Models\Notification; |
| 8 | 8 | use FluentCommunity\App\Models\NotificationSubscriber; |
| 9 | -use FluentCommunity\App\Models\Reaction; | |
| 10 | 9 | |
| 11 | 10 | class CleanupHandler |
| 12 | 11 | { |
| 13 | 12 | public function register() |
| @@ -64,14 +63,8 @@ | ||
| 64 | 63 | $feed->reactions()->delete(); |
| 65 | 64 | $feed->activities()->delete(); |
| 66 | 65 | $this->queueMediaDelete($feed->media); |
| 67 | 66 | |
| 68 | - if ($feed->comtent_type == 'survey') { | |
| 69 | - Reaction::where('type', 'survey_vote') | |
| 70 | - ->where('object_id', $feed->id) | |
| 71 | - ->delete(); | |
| 72 | - } | |
| 73 | - | |
| 74 | 67 | // Loop is used to delete notification with notified user data from fcom_notification_users table |
| 75 | 68 | foreach ($feed->notifications as $notification) { |
| 76 | 69 | $notification->delete(); |
| 77 | 70 | } |
| @@ -197,14 +190,15 @@ | ||
| 197 | 190 | $ids[] = $notification->id; |
| 198 | 191 | } |
| 199 | 192 | |
| 200 | 193 | if (!$ids) { |
| 201 | - | |
| 202 | 194 | // Let's delete meta data |
| 203 | - Utility::getApp('db')->table('fcom_meta')->whereIn('meta_key', [ | |
| 204 | - '_last_mention_email_user_id', | |
| 205 | - '_last_email_user_id' | |
| 206 | - ]) | |
| 195 | + Utility::getApp('db')->table('fcom_meta') | |
| 196 | + ->where('object_type', 'feed') | |
| 197 | + ->whereIn('meta_key', [ | |
| 198 | + '_last_mention_email_user_id', | |
| 199 | + '_last_email_user_id' | |
| 200 | + ]) | |
| 207 | 201 | ->limit(9000) |
| 208 | 202 | ->where('created_at', '<', gmdate('Y-m-d H:i:s', strtotime('-1 week'))) |
| 209 | 203 | ->delete(); |
| 210 | 204 | |
| @@ -255,8 +249,9 @@ | ||
| 255 | 249 | * |
| 256 | 250 | * fcom_meta where object_type = user and object_id = user_id |
| 257 | 251 | * |
| 258 | 252 | * fcom_notification_users where user_id = user_id |
| 253 | + * fcom_notification_prefs where user_id = user_id | |
| 259 | 254 | * fcom_post_comments where user_id = user_id |
| 260 | 255 | * fcom_post_reactions where user_id = user_id |
| 261 | 256 | * fcom_posts where user_id = user_id & type = text |
| 262 | 257 | * fcom_space_user where user_id = user_id |
| @@ -285,8 +280,11 @@ | ||
| 285 | 280 | Utility::getApp('db')->table('fcom_meta')->where('object_type', 'user')->where('object_id', $userId)->delete(); |
| 286 | 281 | |
| 287 | 282 | // notifications |
| 288 | 283 | Utility::getApp('db')->table('fcom_notification_users')->where('user_id', $userId)->delete(); |
| 284 | + | |
| 285 | + // notification preferences | |
| 286 | + Utility::getApp('db')->table('fcom_notification_prefs')->where('user_id', $userId)->delete(); | |
| 289 | 287 | |
| 290 | 288 | // comments |
| 291 | 289 | Utility::getApp('db')->table('fcom_post_comments')->where('user_id', $userId)->delete(); |
| 292 | 290 | |