remove chat data and ownerCalendar

This commit is contained in:
Peter Maquiran
2024-11-06 08:24:37 +01:00
parent 52d333ad16
commit ecb2f6c08e
39 changed files with 1845 additions and 264 deletions
+6
View File
@@ -0,0 +1,6 @@
export class Preference {
LoginPreference = null
UrlBeforeInactivity= ''
Inactivity= true
PIN = ''
}
+58
View File
@@ -0,0 +1,58 @@
import { z } from "zod";
import { SHA1 } from 'crypto-js'
import { localstoreService } from "src/app/store/localstore.service";
// Define the schema for the user object
const UserSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
adUserSID: z.string(),
});
// Define the schema for the main response object
const UserDataSchema = z.object({
user: UserSchema,
authorization: z.string(),
refreshToken: z.string(),
permissions: z.array(z.number()),
});
export type IUser = z.infer<typeof UserDataSchema>
export class UserEntity {
wxUserId: number
wxFullName: string
wxeMail: string
role: string
roleId: number
userPhoto: string
adUserSID: string
authorization: string
refreshToken: string
permissions: number[]
Profile: 'PR' | 'MDGPR'| 'Consultant'| 'SGGPR'| 'Unknown'
constructor(input: IUser) {
Object.assign(this, input)
if (input) {
if (input?.user?.roleId == 100000014) {
this.Profile = 'PR'
} else if (input.user.roleId == 100000011) {
this.Profile = 'MDGPR'
} else if (input.user.roleId == 99999872) {
this.Profile = 'Consultant'
} else if (input.user.roleId == 99999886) {
this.Profile = 'SGGPR'
} else {
this.Profile = 'Unknown'
}
}
}
}
@@ -0,0 +1,16 @@
import { HttpErrorResponse } from "@angular/common/http";
import { Result } from "neverthrow";
import { HttpResult } from "src/app/infra/http/type";
import { UserLoginInput, UserLoginOutput } from "../use-case/user-login-use-case.service";
import { z } from "zod";
const UserRepositoryLoginParams = z.object({
Auth: z.string(),
ChannelId: z.number()
})
export type IUserRepositoryLoginParams = z.infer<typeof UserRepositoryLoginParams>
export abstract class IUserRemoteRepository {
abstract login(input: IUserRepositoryLoginParams): Promise<Result<HttpResult<UserLoginOutput>, HttpErrorResponse>>
}
@@ -0,0 +1,100 @@
import { Injectable } from '@angular/core';
import { z } from 'zod';
import { IUserRemoteRepository } from '../repository/user-remote-repository';
import { XTracerAsync, TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
import { zodSafeValidation } from 'src/app/utils/zodValidation';
import { AlertController, Platform } from '@ionic/angular';
import { AESEncrypt } from 'src/app/services/aesencrypt.service';
const UserLoginInputSchema = z.object({
username: z.string(),
password: z.string(),
domainName: z.string(),
BasicAuthKey: z.string()
})
export type UserLoginInput = z.infer<typeof UserLoginInputSchema>
// Define the schema for the user object
const UserSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
adUserSID: z.string(),
});
// Define the schema for the main response object
const UserLoginOutputSchema = z.object({
user: UserSchema,
authorization: z.string(),
refreshToken: z.string(),
permissions: z.array(z.number()),
});
// Define the main schema for the response
const LoginUserResponseSchema = z.object({
success: z.boolean(),
message: z.nullable(z.string()), // Message can be null
data: UserLoginOutputSchema,
});
export type UserLoginOutput = z.infer<typeof LoginUserResponseSchema>
@Injectable({
providedIn: 'root'
})
export class UserLoginUseCaseService {
constructor(
private userRemoteRepository: IUserRemoteRepository,
private aesencrypt: AESEncrypt,
private platform: Platform
) { }
@XTracerAsync({name:'UserLoginUseCaseService', module:'user', bugPrint: true})
async execute(input: UserLoginInput, tracing?: TracingType) {
const validation = zodSafeValidation<UserLoginInput>(UserLoginInputSchema, input)
if(validation.isOk()) {
let channelId;
if ( this.platform.is('desktop') || this.platform.is("mobileweb")){
channelId = 2
} else {
channelId = 1
}
const auth = btoa(input.username + ':' + this.aesencrypt.encrypt(input.password, input.username))
const result = await this.userRemoteRepository.login({
Auth: auth,
ChannelId: channelId
})
if(result.isOk()) {
if(result.value) {
}
}
return result.map(e => e.data.data)
} else {
tracing.setAttribute('parameter error','true')
// Logger.error('failed to send message doe to invalid attachment', {
// zodErrorList: validation.error.errors,
// data: data
// })
return validation
}
}
}