mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 06:49:23 +00:00
Update last user activity
This commit is contained in:
parent
d443551405
commit
17407f964b
@ -105,11 +105,16 @@ export class AccountController {
|
|||||||
/**
|
/**
|
||||||
* Get current user ID
|
* Get current user ID
|
||||||
*
|
*
|
||||||
* @param handler
|
* @param h Request handler
|
||||||
*/
|
*/
|
||||||
public static CurrentUserID(handler: RequestHandler) {
|
public static async CurrentUserID(h: RequestHandler) {
|
||||||
handler.send({
|
|
||||||
userID: handler.getUserId()
|
// Update user activity (if allowed)
|
||||||
|
if(!h.postBool("incognito", false))
|
||||||
|
await AccountHelper.UpdateLastActivity(h.getUserId())
|
||||||
|
|
||||||
|
h.send({
|
||||||
|
userID: h.getUserId()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import { FriendsHelper } from "../helpers/FriendsHelper";
|
|||||||
import { UserHelper } from "../helpers/UserHelper";
|
import { UserHelper } from "../helpers/UserHelper";
|
||||||
import { NotifEventType } from "../entities/Notification";
|
import { NotifEventType } from "../entities/Notification";
|
||||||
import { NotificationsHelper } from "../helpers/NotificationsHelper";
|
import { NotificationsHelper } from "../helpers/NotificationsHelper";
|
||||||
|
import { AccountHelper } from "../helpers/AccountHelper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Friends controller
|
* Friends controller
|
||||||
@ -22,7 +23,9 @@ export class FriendsController {
|
|||||||
const returnAllInfo = h.postBool("complete", false);
|
const returnAllInfo = h.postBool("complete", false);
|
||||||
const list = await FriendsHelper.GetList(h.getUserId());
|
const list = await FriendsHelper.GetList(h.getUserId());
|
||||||
|
|
||||||
// TODO : update user activity (if allowed)
|
// Update user activity (if allowed)
|
||||||
|
if(!h.postBool("incognito", false))
|
||||||
|
await AccountHelper.UpdateLastActivity(h.getUserId())
|
||||||
|
|
||||||
h.send(list.map((f) => this.FriendToAPI(f, returnAllInfo)));
|
h.send(list.map((f) => this.FriendToAPI(f, returnAllInfo)));
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,23 @@ export class AccountHelper {
|
|||||||
return result == null ? -1 : result.ID;
|
return result == null ? -1 : result.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the last activity time of the user
|
||||||
|
*
|
||||||
|
* @param userID Target user ID
|
||||||
|
*/
|
||||||
|
public static async UpdateLastActivity(userID: number) {
|
||||||
|
await DatabaseHelper.UpdateRows({
|
||||||
|
table: USER_TABLE,
|
||||||
|
where: {
|
||||||
|
ID: userID
|
||||||
|
},
|
||||||
|
set: {
|
||||||
|
last_activity: time()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check out whether a virtual directory is available or not
|
* Check out whether a virtual directory is available or not
|
||||||
|
Loading…
Reference in New Issue
Block a user