diff --git a/src/Api/Serializer/CurrentUserSerializer.php b/src/Api/Serializer/CurrentUserSerializer.php index d4d6bdcbf..667cd3592 100644 --- a/src/Api/Serializer/CurrentUserSerializer.php +++ b/src/Api/Serializer/CurrentUserSerializer.php @@ -24,7 +24,7 @@ class CurrentUserSerializer extends UserSerializer $attributes += [ 'isActivated' => (bool) $user->is_email_confirmed, 'email' => $user->email, - 'readTime' => $this->formatDate($user->read_notifications_at), + 'readTime' => $this->formatDate($user->marked_all_as_read_at), 'unreadNotificationsCount' => (int) $user->getUnreadNotificationsCount(), 'newNotificationsCount' => (int) $user->getNewNotificationsCount(), 'preferences' => (array) $user->preferences diff --git a/src/Discussion/DiscussionRepository.php b/src/Discussion/DiscussionRepository.php index 68862b5a1..de0b7ee36 100644 --- a/src/Discussion/DiscussionRepository.php +++ b/src/Discussion/DiscussionRepository.php @@ -51,7 +51,7 @@ class DiscussionRepository { return Discussion::leftJoin('discussions_users', 'discussions_users.discussion_id', '=', 'discussions.id') ->where('user_id', $user->id) - ->whereRaw('read_number >= last_post_number') + ->whereRaw('last_read_post_number >= last_post_number') ->pluck('id') ->all(); } diff --git a/src/Discussion/UserState.php b/src/Discussion/UserState.php index ee856cff5..fc964d450 100644 --- a/src/Discussion/UserState.php +++ b/src/Discussion/UserState.php @@ -57,8 +57,8 @@ class UserState extends AbstractModel */ public function read($number) { - if ($number > $this->last_read_at) { - $this->last_read_at = $number; + if ($number > $this->last_read_post_number) { + $this->last_read_post_number = $number; $this->last_read_at = Carbon::now(); $this->raise(new UserRead($this)); diff --git a/src/Http/Middleware/CollectGarbage.php b/src/Http/Middleware/CollectGarbage.php index 361ec172c..9b0da016c 100644 --- a/src/Http/Middleware/CollectGarbage.php +++ b/src/Http/Middleware/CollectGarbage.php @@ -58,7 +58,7 @@ class CollectGarbage implements Middleware $time = Carbon::now()->timestamp; - AccessToken::whereRaw('last_activity <= ? - lifetime', [$time])->delete(); + AccessToken::whereRaw('last_activity_at <= ? - lifetime_seconds', [$time])->delete(); $earliestToKeep = date('Y-m-d H:i:s', $time - 24 * 60 * 60); diff --git a/src/Http/Rememberer.php b/src/Http/Rememberer.php index 1d25df007..17b1673d2 100644 --- a/src/Http/Rememberer.php +++ b/src/Http/Rememberer.php @@ -33,12 +33,12 @@ class Rememberer public function remember(ResponseInterface $response, AccessToken $token) { - $token->lifetime = 5 * 365 * 24 * 60 * 60; // 5 years + $token->lifetime_seconds = 5 * 365 * 24 * 60 * 60; // 5 years $token->save(); return FigResponseCookies::set( $response, - $this->cookie->make(self::COOKIE_NAME, $token->id, $token->lifetime) + $this->cookie->make(self::COOKIE_NAME, $token->token, $token->lifetime_seconds) ); } diff --git a/src/Notification/Command/ReadNotificationHandler.php b/src/Notification/Command/ReadNotificationHandler.php index 41da8e781..f26cb7712 100644 --- a/src/Notification/Command/ReadNotificationHandler.php +++ b/src/Notification/Command/ReadNotificationHandler.php @@ -11,6 +11,7 @@ namespace Flarum\Notification\Command; +use Carbon\Carbon; use Flarum\Notification\Notification; use Flarum\User\AssertPermissionTrait; @@ -36,7 +37,7 @@ class ReadNotificationHandler 'type' => $notification->type, 'subject_id' => $notification->subject_id ]) - ->update(['is_read' => true]); + ->update(['read_at' => Carbon::now()]); $notification->is_read = true; diff --git a/src/Notification/NotificationSyncer.php b/src/Notification/NotificationSyncer.php index b8cd39b48..e4b21af80 100644 --- a/src/Notification/NotificationSyncer.php +++ b/src/Notification/NotificationSyncer.php @@ -179,7 +179,7 @@ class NotificationSyncer array_map(function (User $user) use ($attributes, $now) { return $attributes + [ 'user_id' => $user->id, - 'time' => $now + 'created_at' => $now ]; }, $recipients) );