✨ Last seen at
This commit is contained in:
@@ -179,3 +179,14 @@ func RecycleUnConfirmAccount() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetAccountLastSeen(uid uint) error {
|
||||
var profile models.AccountProfile
|
||||
if err := database.C.Where("account_id = ?", uid).First(&profile).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
profile.LastSeenAt = lo.ToPtr(time.Now())
|
||||
|
||||
return database.C.Save(&profile).Error
|
||||
}
|
||||
|
@@ -28,4 +28,10 @@ func ClientUnregister(user models.Account, conn *websocket.Conn) {
|
||||
}
|
||||
delete(wsConn[user.ID], conn)
|
||||
wsMutex.Unlock()
|
||||
|
||||
if status, err := GetStatus(user.ID); err != nil || !status.IsInvisible {
|
||||
if len(wsConn[user.ID]) == 0 {
|
||||
_ = SetAccountLastSeen(user.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user