clear agenda cache

This commit is contained in:
Peter Maquiran
2023-01-18 11:38:21 +01:00
parent 711e9fc640
commit 46296813b8
8 changed files with 114 additions and 104 deletions
+1
View File
@@ -123,6 +123,7 @@ export class LoginPage implements OnInit {
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
this.changeProfileService.run();
if(attempt.ChatData) {
+6 -2
View File
@@ -317,8 +317,12 @@ export class ChatSystemService {
}
this.RochetChatConnectorService.streamNotifyLogged().then((subscription=>{
console.log(subscription)
}))
// this.RochetChatConnectorService.subStreamNotifyUser().then((subscription=>{
// console.log(subscription)
// }))
}
/**
@@ -406,7 +410,7 @@ export class ChatSystemService {
let roomId = this.getRoomId(roomData);
if (setData.name != 'Rocket Cat') {
if (setData.name != 'Rocket Cat' && setData.name != 'general' ) {
// create room
if(!this.roomExist(roomId)) {
let room:RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService)
@@ -437,6 +437,35 @@ export class RochetChatConnectorService {
}
subStreamNotifyUser(param?: any) {
const requestId = uuidv4()
let message = {
msg: "sub",
id: requestId,
name: "stream-notify-user",
params:[
`${SessionStore.user.ChatData.data.userId}/notification`,
param
]
}
this.ws.send({message, requestId})
return new Promise((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId ) { // same request send
resolve(message)
return true
}
}})
});
}
receiveStreamNotifyRoom(funx: Function) {
this.ws.registerCallback({
+54 -79
View File
@@ -20,7 +20,6 @@ import { SessionStore } from '../store/session.service';
export class EventsService {
authheader = {};
loggeduser: UserSession;
headers: HttpHeaders;
headersPrOficial: HttpHeaders;
@@ -37,25 +36,17 @@ export class EventsService {
headersSharedOficial: HttpHeaders;
headersSharedPessoal: HttpHeaders;
hasSharedCalendar = false
hasOwnCalendar = false
calendarIds = []
usersCalendarIds = []
hasSharedCalendar = false;
hasSharedOficial: boolean = false;
hasSharedPessoal: boolean = false;
hasOwnOficial: boolean = false;
hasOwnPessoal: boolean = false;
userCalendarNameSharedOficial = '';
userCalendarNameSharedPessoal = '';
userCalendarNameOwnOficial = '';
userCalendarNameOwnPessoal = '';
hasOwnCalendar = false
calendarNames = {}
@@ -73,7 +64,14 @@ export class EventsService {
private storage: Storage,
private backgroundservice: BackgroundService) {
this.loggeduser = SessionStore.user;
this.setHeader()
this.changeProfileService.registerCallback(() => {
this.setHeader()
})
}
async setHeader () {
this.headers = new HttpHeaders();
this.headersMdOficial = new HttpHeaders();
@@ -92,16 +90,14 @@ export class EventsService {
this.headerSharedOficial= new HttpHeaders();
this.headerSharedPessoal= new HttpHeaders();
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
this.setHeader()
this.changeProfileService.registerCallback(() => {
this.loggeduser = SessionStore.user;
this.setHeader()
})
}
async setHeader () {
this.usersCalendarIds = [];
this.calendarNames = {}
this.calendarIds = []
this.calendarNamesAry = []
this.calendarNamesType = {}
this.hasSharedCalendar = false
this.hasSharedOficial = false
@@ -110,32 +106,11 @@ export class EventsService {
this.hasOwnCalendar = false
this.hasOwnOficial = false
this.hasOwnPessoal = false
this.headers = new HttpHeaders();
this.headerOwnOficial= new HttpHeaders();
this.headerOwnPessoal= new HttpHeaders();
this.headerSharedOficial= new HttpHeaders();
this.headerSharedPessoal= new HttpHeaders();
if (SessionStore.user) {
if (SessionStore.user.Profile == 'MDGPR') {
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
this.userCalendarNameSharedOficial = '';
this.userCalendarNameSharedPessoal = '';
this.userCalendarNameOwnOficial = '';
this.userCalendarNameOwnPessoal = '';
this.usersCalendarIds = [];
this.calendarNames = {}
this.calendarNamesAry = []
this.calendarNamesType = {}
if (this.loggeduser) {
if (this.loggeduser.Profile == 'MDGPR') {
for (let calendar of this.loggeduser.OwnerCalendars) {
for (let calendar of SessionStore.user.OwnerCalendars) {
this.hasAnyCalendar = false
if (calendar.CalendarName == 'Oficial') {
@@ -143,7 +118,7 @@ export class EventsService {
this.hasOwnOficial = true
this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdOficial = this.headersMdOficial.set('Authorization', SessionStore.user.BasicAuthKey);
this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId);
this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
@@ -151,21 +126,21 @@ export class EventsService {
this.hasOwnPessoal = true
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', SessionStore.user.BasicAuthKey);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
}
}
for (let sharedCalendar of this.loggeduser.SharedCalendars) {
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
this.hasAnyCalendar = false
if (sharedCalendar.CalendarName == 'Oficial') {
this.hasSharedOficial = true
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', SessionStore.user.BasicAuthKey);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
}
@@ -173,7 +148,7 @@ export class EventsService {
this.hasSharedPessoal = true
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', SessionStore.user.BasicAuthKey);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
}
@@ -181,15 +156,15 @@ export class EventsService {
}
else if (this.loggeduser.Profile == 'PR') {
else if (SessionStore.user.Profile == 'PR') {
for (let calendar of this.loggeduser.OwnerCalendars) {
for (let calendar of SessionStore.user.OwnerCalendars) {
this.hasAnyCalendar = false
if (calendar.CalendarName == 'Oficial') {
this.hasOwnOficial = true
this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrOficial = this.headersPrOficial.set('Authorization', SessionStore.user.BasicAuthKey);
this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId);
this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
@@ -197,7 +172,7 @@ export class EventsService {
this.hasOwnPessoal = true
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', SessionStore.user.BasicAuthKey);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
@@ -206,7 +181,7 @@ export class EventsService {
}
for (let calendar of this.loggeduser.OwnerCalendars) {
for (let calendar of SessionStore.user.OwnerCalendars) {
this.hasAnyCalendar = false
if(!this.usersCalendarIds.includes(calendar.OwnerUserId)) {
this.usersCalendarIds.push(calendar.OwnerUserId)
@@ -222,7 +197,7 @@ export class EventsService {
this.hasOwnOficial = true
this.headerOwnOficial = this.headerOwnOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headerOwnOficial = this.headerOwnOficial.set('Authorization', SessionStore.user.BasicAuthKey);
this.headerOwnOficial = this.headerOwnOficial.set('CalendarId', calendar.CalendarId);
this.headerOwnOficial = this.headerOwnOficial.set('CalendarRoleId', calendar.CalendarRoleId);
this.headerOwnOficial = this.headerOwnOficial.set('CalendarName', calendar.CalendarName);
@@ -231,14 +206,14 @@ export class EventsService {
this.hasOwnPessoal = true
this.headerOwnPessoal = this.headerOwnPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headerOwnPessoal = this.headerOwnPessoal.set('Authorization', SessionStore.user.BasicAuthKey);
this.headerOwnPessoal =this.headerOwnPessoal.set('CalendarId', calendar.CalendarId);
this.headerOwnPessoal =this.headerOwnPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
this.headerOwnPessoal = this.headerOwnPessoal.set('CalendarName', calendar.CalendarName);
}
}
for (let sharedCalendar of this.loggeduser.SharedCalendars) {
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
this.hasAnyCalendar = false
if(!this.usersCalendarIds.includes(sharedCalendar.OwnerUserId)) {
@@ -254,7 +229,7 @@ export class EventsService {
if (sharedCalendar.CalendarName == 'Oficial') {
this.hasSharedOficial = true
this.headerSharedOficial = this.headerSharedOficial.set('Authorization',this.loggeduser.BasicAuthKey);
this.headerSharedOficial = this.headerSharedOficial.set('Authorization',SessionStore.user.BasicAuthKey);
this.headerSharedOficial = this.headerSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
this.headerSharedOficial = this.headerSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
this.headerSharedOficial = this.headerSharedOficial.set('CalendarName', sharedCalendar.CalendarName);
@@ -263,7 +238,7 @@ export class EventsService {
this.hasSharedPessoal = true
this.headerSharedPessoal = this.headerSharedPessoal.set('Authorization',this.loggeduser.BasicAuthKey);
this.headerSharedPessoal = this.headerSharedPessoal.set('Authorization',SessionStore.user.BasicAuthKey);
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarName', sharedCalendar.CalendarName);
@@ -271,7 +246,7 @@ export class EventsService {
}
for (let sharedCalendar of this.loggeduser.SharedCalendars) {
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
this.hasAnyCalendar = false
if(sharedCalendar?.OwnerUserId) {
this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> {
@@ -291,7 +266,7 @@ export class EventsService {
}
for (let sharedCalendar of this.loggeduser.OwnerCalendars) {
for (let sharedCalendar of SessionStore.user.OwnerCalendars) {
this.hasAnyCalendar = false
this.calendarNames[sharedCalendar.CalendarId] = 'Meu calendario'
@@ -326,13 +301,13 @@ export class EventsService {
isMyEvent(event: any) {
for (let calendar of this.loggeduser.OwnerCalendars) {
for (let calendar of SessionStore.user.OwnerCalendars) {
if(event.CalendarId == calendar.CalendarId) {
return true
}
}
for (let sharedCalendar of this.loggeduser.SharedCalendars) {
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
if(event.CalendarId == sharedCalendar.CalendarId) {
return false
}
@@ -438,7 +413,7 @@ export class EventsService {
let prO = [], prP = [];
for (let calendar of this.loggeduser.OwnerCalendars) {
for (let calendar of SessionStore.user.OwnerCalendars) {
if (calendar.CalendarName == 'Oficial') {
prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise();
if(!Array.isArray(prO)) {
@@ -521,10 +496,10 @@ export class EventsService {
let result = []
for (let sharedCalendar of this.loggeduser.SharedCalendars) {
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
var header = new HttpHeaders();
header = header.set('Authorization', this.loggeduser.BasicAuthKey);
header = header.set('Authorization', SessionStore.user.BasicAuthKey);
header = header.set('CalendarId', sharedCalendar.CalendarId);
header = header.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
header = header.set('CalendarName', sharedCalendar.CalendarName);
@@ -591,7 +566,7 @@ export class EventsService {
let prO = [], prP = [];
for(let calendar of this.loggeduser.SharedCalendars) {
for(let calendar of SessionStore.user.SharedCalendars) {
if (calendar.CalendarName == 'Oficial') {
prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise();
}
@@ -745,10 +720,10 @@ export class EventsService {
this.headers['CalendarName'] = event.CalendarName
if (event.CalendarName == 'Oficial') {
if (this.loggeduser.Profile == 'MDGPR') {
if (SessionStore.user.Profile == 'MDGPR') {
this.headers = this.headersMdOficial;
}
else if (this.loggeduser.Profile == 'PR') {
else if (SessionStore.user.Profile == 'PR') {
this.headers = this.headersPrOficial;
} else {
@@ -767,10 +742,10 @@ export class EventsService {
}
}
else {
if (this.loggeduser.Profile == 'MDGPR') {
if (SessionStore.user.Profile == 'MDGPR') {
this.headers = this.headersMdPessoal;
}
else if (this.loggeduser.Profile == 'PR') {
else if (SessionStore.user.Profile == 'PR') {
this.headers = this.headersPrPessoal;
}
else {
@@ -916,7 +891,7 @@ export class EventsService {
let options;
switch (this.loggeduser.Profile) {
switch (SessionStore.user.Profile) {
case 'MDGPR':
if (calendarName == 'Pessoal') {
options = {
@@ -974,7 +949,7 @@ export class EventsService {
let options;
if(this.loggeduser.Profile == 'MDGPR') {
if(SessionStore.user.Profile == 'MDGPR') {
if (calendarName == 'Pessoal') {
options = {
headers: this.headersMdPessoal,
@@ -988,7 +963,7 @@ export class EventsService {
};
}
}
else if (this.loggeduser.Profile == 'PR') {
else if (SessionStore.user.Profile == 'PR') {
if (calendarName == 'Pessoal') {
options = {
headers: this.headersPrPessoal,
@@ -1050,7 +1025,7 @@ export class EventsService {
params = params.set("SerialNumber", serialNumber);
params = params.set("applicationID", applicationID);
switch (this.loggeduser.Profile) {
switch (SessionStore.user.Profile) {
case 'MDGPR':
if (body.CalendarName == 'Pessoal') {
options = {
@@ -1121,7 +1096,7 @@ export class EventsService {
params = params.set("SerialNumber", serialNumber);
params = params.set("applicationID", applicationID);
switch (this.loggeduser.Profile) {
switch (SessionStore.user.Profile) {
case 'MDGPR':
if (body.CalendarName == 'Pessoal') {
options = {