mirror of
https://github.com/flarum/framework.git
synced 2025-04-27 07:04:03 +08:00
API for marking all as read
This commit is contained in:
parent
eec50f687c
commit
8e6011e8d0
@ -29,6 +29,7 @@ class UserSerializer extends UserBasicSerializer
|
|||||||
$attributes += [
|
$attributes += [
|
||||||
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
|
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
|
||||||
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
|
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
|
||||||
|
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
|
||||||
'discussionsCount' => (int) $user->discussions_count,
|
'discussionsCount' => (int) $user->discussions_count,
|
||||||
'postsCount' => (int) $user->posts_count,
|
'postsCount' => (int) $user->posts_count,
|
||||||
'canEdit' => $user->permission('edit'),
|
'canEdit' => $user->permission('edit'),
|
||||||
|
@ -12,6 +12,8 @@ class EditUserCommand
|
|||||||
|
|
||||||
public $password;
|
public $password;
|
||||||
|
|
||||||
|
public $readTime;
|
||||||
|
|
||||||
public function __construct($userId, $user)
|
public function __construct($userId, $user)
|
||||||
{
|
{
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
|
@ -36,6 +36,10 @@ class EditUserCommandHandler implements CommandHandler
|
|||||||
$userToEdit->password = $command->password;
|
$userToEdit->password = $command->password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($command->readTime)) {
|
||||||
|
$userToEdit->read_time = time();
|
||||||
|
}
|
||||||
|
|
||||||
Event::fire('Flarum.Core.Users.Commands.EditUser.UserWillBeSaved', [$userToEdit, $command]);
|
Event::fire('Flarum.Core.Users.Commands.EditUser.UserWillBeSaved', [$userToEdit, $command]);
|
||||||
|
|
||||||
$this->userRepo->save($userToEdit);
|
$this->userRepo->save($userToEdit);
|
||||||
|
@ -93,7 +93,7 @@ class User extends Entity implements UserInterface, RemindableInterface
|
|||||||
|
|
||||||
public function getDates()
|
public function getDates()
|
||||||
{
|
{
|
||||||
return ['join_time', 'last_seen_time'];
|
return ['join_time', 'last_seen_time', 'read_time'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvatarUrlAttribute()
|
public function getAvatarUrlAttribute()
|
||||||
|
@ -22,6 +22,7 @@ class CreateUsersTable extends Migration {
|
|||||||
$table->dateTime('join_time');
|
$table->dateTime('join_time');
|
||||||
$table->string('time_zone');
|
$table->string('time_zone');
|
||||||
$table->dateTime('last_seen_time')->nullable();
|
$table->dateTime('last_seen_time')->nullable();
|
||||||
|
$table->dateTime('read_time')->nullable();
|
||||||
$table->integer('discussions_count')->unsigned()->default(0);
|
$table->integer('discussions_count')->unsigned()->default(0);
|
||||||
$table->integer('posts_count')->unsigned()->default(0);
|
$table->integer('posts_count')->unsigned()->default(0);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user