mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Start to add support for incognito mode
This commit is contained in:
parent
23733b229e
commit
99af649cfe
@ -220,7 +220,9 @@ export class FriendsController {
|
|||||||
ID_friend: friend.friendID,
|
ID_friend: friend.friendID,
|
||||||
accepted: friend.accepted ? 1 : 0,
|
accepted: friend.accepted ? 1 : 0,
|
||||||
time_last_activity:
|
time_last_activity:
|
||||||
UserWebSocketController.IsConnected(friend.friendID) ? time() : friend.lastActivityTime
|
UserWebSocketController.IsConnected(friend.friendID) &&
|
||||||
|
!UserWebSocketController.IsIcognito(friend.friendID)
|
||||||
|
? time() : friend.lastActivityTime
|
||||||
}
|
}
|
||||||
|
|
||||||
if(full) {
|
if(full) {
|
||||||
|
@ -19,14 +19,16 @@ interface PendingRequests {
|
|||||||
time: number,
|
time: number,
|
||||||
clientID: number,
|
clientID: number,
|
||||||
userID: number,
|
userID: number,
|
||||||
token: string
|
token: string,
|
||||||
|
incognito: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ActiveClient {
|
export interface ActiveClient {
|
||||||
socketID: string,
|
socketID: string,
|
||||||
clientID: number,
|
clientID: number,
|
||||||
userID: number,
|
userID: number,
|
||||||
ws: ws
|
ws: ws,
|
||||||
|
incognito: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tokens are valid only 10 seconds after they are generated
|
// Tokens are valid only 10 seconds after they are generated
|
||||||
@ -70,7 +72,8 @@ export class UserWebSocketController {
|
|||||||
time: time(),
|
time: time(),
|
||||||
clientID: h.getClientInfo().id,
|
clientID: h.getClientInfo().id,
|
||||||
userID: h.getUserId(),
|
userID: h.getUserId(),
|
||||||
token: token
|
token: token,
|
||||||
|
incognito: h.postBool("incognito", false)
|
||||||
});
|
});
|
||||||
|
|
||||||
h.send({
|
h.send({
|
||||||
@ -114,7 +117,8 @@ export class UserWebSocketController {
|
|||||||
socketID: randomStr(30),
|
socketID: randomStr(30),
|
||||||
clientID: entry.clientID,
|
clientID: entry.clientID,
|
||||||
userID: entry.userID,
|
userID: entry.userID,
|
||||||
ws: ws
|
ws: ws,
|
||||||
|
incognito: entry.incognito
|
||||||
}
|
}
|
||||||
this.active_clients.push(client);
|
this.active_clients.push(client);
|
||||||
|
|
||||||
@ -228,6 +232,16 @@ export class UserWebSocketController {
|
|||||||
return this.active_clients.find((e) => e.userID == userID) != undefined;
|
return this.active_clients.find((e) => e.userID == userID) != undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check out whether a has all its connections marked as incognito
|
||||||
|
*
|
||||||
|
* @param userID Target user ID
|
||||||
|
*/
|
||||||
|
public static IsIcognito(userID: number) : boolean {
|
||||||
|
return this.IsConnected(userID)
|
||||||
|
&& this.active_clients.find(e => e.userID == userID && !e.incognito) == undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send updated notifications number to some users
|
* Send updated notifications number to some users
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user