converting to MP, just config in accessRights left

This commit is contained in:
STEINNI
2025-10-05 21:24:10 +00:00
parent 03af111d7f
commit 350d37e465
13 changed files with 283 additions and 796 deletions
+16 -30
View File
@@ -1,5 +1,6 @@
import crypto from 'crypto'
import { gatewayActions } from './actions/index.js'
import { RedisSearchLanguages } from 'redis'
export class WssConnexion {
@@ -11,7 +12,7 @@ export class WssConnexion {
this.uuid = options.uuid
this.wssSrv = options.wssSrv
this.debug = options.debug
this.rediscnx = options.rediscnx
this.allRediscnx = options.allRediscnx
this.accessRights = options.accessRights
this.userId = options.userId
this.roles = options.roles
@@ -95,34 +96,17 @@ export class WssConnexion {
// Also think about all possibly active bind(this), which -I guess- also make references preventing GC.
}
async getAwaitingNotifs(){
//TODO : AWAIT this from either Redis and/or ML
// Key: notif destination module, value: either KV with V=nb of notifs, or Array whose length is nb of notifs
let notifs = { // TEST EXAMPLE
"unreadChats": {
"chan001" : 2,
"chan002" : 10,
"chan003" : 7,
},
"OTS": [ "fallimi", "infosca" ],
"OtherNotifDest" : []
};
return(notifs);
}
subscribeMandatoryChans(){
let mandaChans = this.accessRights.mustSubscribe(this.userId, this.roles)
mandaChans.push('userchans:'+this.userId); // Add user private chan
mandaChans = mandaChans.map(item=>this.config.redis.basePrefix+item)
for(var chan of mandaChans){
if(!(chan in this.rediscnx.subscriptions)) this.rediscnx.subscriptions[chan] = [];
if(this.subscriptions.indexOf(chan)<0) {
this.subscriptions.push(chan);
this.rediscnx.subscriptions[chan].push(this.uuid);
for(let rediscnx of this.allRediscnx){
mandaChans = mandaChans.filter(chan => chan.startsWith(rediscnx.redisConfig.chansFilter))
mandaChans = mandaChans.map(item=>rediscnx.redisConfig.basePrefix+item)
for(var chan of mandaChans){
if(!(chan in rediscnx.subscriptions)) rediscnx.subscriptions[chan] = [];
if(this.subscriptions.indexOf(chan)<0) {
this.subscriptions.push(chan);
rediscnx.subscriptions[chan].push(this.uuid);
}
}
}
this.action_SUBLST('SUBLST', null, '');
@@ -130,11 +114,13 @@ export class WssConnexion {
clearAllSubscriptions(){
for(var chan of this.subscriptions){
if(chan in this.rediscnx.subscriptions) {
this.rediscnx.subscriptions[chan].splice(this.rediscnx.subscriptions[chan].indexOf(this.uuid), 1) ;
for(let rediscnx of this.allRediscnx){
if(chan in rediscnx.subscriptions) {
rediscnx.subscriptions[chan].splice(rediscnx.subscriptions[chan].indexOf(this.uuid), 1)
}
}
}
this.subscriptions = [];
this.subscriptions = []
}
sendErr(action, msg, reqid){