Chore: Add user service method UpdateLastSeenAt (#53309)
* Chore: Add user service method UpdateLastSeenAt * Fix lint
This commit is contained in:
@@ -82,6 +82,10 @@ type ChangeUserPasswordCommand struct {
|
||||
UserID int64 `json:"-"`
|
||||
}
|
||||
|
||||
type UpdateUserLastSeenAtCommand struct {
|
||||
UserID int64
|
||||
}
|
||||
|
||||
func (u *User) NameOrFallback() string {
|
||||
if u.Name != "" {
|
||||
return u.Name
|
||||
|
||||
@@ -12,4 +12,5 @@ type Service interface {
|
||||
GetByEmail(context.Context, *GetUserByEmailQuery) (*User, error)
|
||||
Update(context.Context, *UpdateUserCommand) error
|
||||
ChangePassword(context.Context, *ChangeUserPasswordCommand) error
|
||||
UpdateLastSeenAt(context.Context, *UpdateUserLastSeenAtCommand) error
|
||||
}
|
||||
|
||||
@@ -289,3 +289,11 @@ func (s *Service) ChangePassword(ctx context.Context, cmd *user.ChangeUserPasswo
|
||||
}
|
||||
return s.sqlStore.ChangeUserPassword(ctx, q)
|
||||
}
|
||||
|
||||
// TODO: remove wrapper around sqlstore
|
||||
func (s *Service) UpdateLastSeenAt(ctx context.Context, cmd *user.UpdateUserLastSeenAtCommand) error {
|
||||
q := &models.UpdateUserLastSeenAtCommand{
|
||||
UserId: cmd.UserID,
|
||||
}
|
||||
return s.sqlStore.UpdateUserLastSeenAt(ctx, q)
|
||||
}
|
||||
|
||||
@@ -42,3 +42,7 @@ func (f *FakeUserService) Update(ctx context.Context, cmd *user.UpdateUserComman
|
||||
func (f *FakeUserService) ChangePassword(ctx context.Context, cmd *user.ChangeUserPasswordCommand) error {
|
||||
return f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeUserService) UpdateLastSeenAt(ctx context.Context, cmd *user.UpdateUserLastSeenAtCommand) error {
|
||||
return f.ExpectedError
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user