mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix chat send attchment
This commit is contained in:
@@ -19,16 +19,7 @@ export class MessageMapper {
|
|||||||
roomId: entity.roomId,
|
roomId: entity.roomId,
|
||||||
senderId: entity.sender.wxUserId,
|
senderId: entity.sender.wxUserId,
|
||||||
requestId: entity.requestId || requestId,
|
requestId: entity.requestId || requestId,
|
||||||
attachment: entity.attachments.map((e)=>({
|
attachment: entity.attachments.map((e)=>(e.id)) || [],
|
||||||
fileType:e.fileType,
|
|
||||||
source: e.source,
|
|
||||||
file: e.file,
|
|
||||||
fileName: e.fileName,
|
|
||||||
applicationId: e.applicationId || 0,
|
|
||||||
docId: Number(e.docId) || 0,
|
|
||||||
mimeType: e.mimeType,
|
|
||||||
description: e.description
|
|
||||||
})) || [],
|
|
||||||
deviceId: getInstanceId()
|
deviceId: getInstanceId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { DataSourceReturn } from "src/app/services/Repositorys/type";
|
import { DataSourceReturn } from "src/app/services/Repositorys/type";
|
||||||
import { IMessageGetAllByRoomIdOutPut } from "../../usecase/message/message-get-all-by-room-Id";
|
import { IMessageGetAllByRoomIdOutPut } from "../../usecase/message/message-get-all-by-room-Id";
|
||||||
|
import { MessageAttachmentInput } from "../../usecase/message/message-attachment-upload-use-case.service";
|
||||||
|
import { Result } from "neverthrow";
|
||||||
|
import { HttpErrorResponse } from "@angular/common/http";
|
||||||
|
|
||||||
export interface IGetMessagesFromRoomParams {
|
export interface IGetMessagesFromRoomParams {
|
||||||
roomId: string
|
roomId: string
|
||||||
@@ -8,4 +11,5 @@ export interface IGetMessagesFromRoomParams {
|
|||||||
|
|
||||||
export abstract class IMessageRemoteRepository {
|
export abstract class IMessageRemoteRepository {
|
||||||
abstract getMessagesFromRoom(input: IGetMessagesFromRoomParams): DataSourceReturn<IMessageGetAllByRoomIdOutPut>
|
abstract getMessagesFromRoom(input: IGetMessagesFromRoomParams): DataSourceReturn<IMessageGetAllByRoomIdOutPut>
|
||||||
|
abstract messageAttachmentUpload(input: MessageAttachmentInput): Promise<Result<String, HttpErrorResponse>>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import { SocketMessage } from "src/app/infra/socket/signalR/signalR";
|
|||||||
export abstract class IMessageSocketRepository {
|
export abstract class IMessageSocketRepository {
|
||||||
|
|
||||||
abstract connect(): Promise<Result<HubConnection, false>>
|
abstract connect(): Promise<Result<HubConnection, false>>
|
||||||
abstract sendGroupMessage(data: MessageInputDTO): Promise<Result<MessageCreateOutPutDataDTO, any>>
|
abstract sendGroupMessage(data: MessageInputDTO): Promise<Result<MessageOutPutDataDTO, any>>
|
||||||
abstract sendDirectMessage(data: MessageInputDTO): Promise<Result<MessageCreateOutPutDataDTO, any>>
|
abstract sendDirectMessage(data: MessageInputDTO): Promise<Result<MessageOutPutDataDTO, any>>
|
||||||
|
|
||||||
// abstract sendDeliverAt(): Promise<Result<any, any>>
|
// abstract sendDeliverAt(): Promise<Result<any, any>>
|
||||||
abstract sendReadAt(data: MessageMarkAsReadInput): Promise<Result<any, any>>
|
abstract sendReadAt(data: MessageMarkAsReadInput): Promise<Result<any, any>>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { base64Schema } from 'src/app/utils/zod';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { MessageAttachmentFileType, MessageAttachmentSource } from '../../entity/message';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const MessageAttachmentDTOSchema = z.object({
|
||||||
|
fileType: z.nativeEnum(MessageAttachmentFileType),
|
||||||
|
source: z.nativeEnum(MessageAttachmentSource),
|
||||||
|
file: base64Schema.optional(),
|
||||||
|
fileName: z.string().optional(),
|
||||||
|
applicationId: z.number(),
|
||||||
|
docId: z.number(),
|
||||||
|
mimeType: z.string().nullable().optional(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
senderId: z.number().optional(),
|
||||||
|
});
|
||||||
|
export type MessageAttachmentInput = z.infer<typeof MessageAttachmentDTOSchema>
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class MessageAttachmentUploadUseCaseService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
execute(input: MessageAttachmentInput) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { IMessage, MessageAttachmentSource, MessageEntity, MessageEntitySchema, } from '../../entity/message';
|
|
||||||
import { z } from 'zod';
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
|
||||||
import { createBlobFromBase64, createDataURL } from 'src/app/utils/ToBase64';
|
|
||||||
import { zodSafeValidation } from 'src/app/utils/zodValidation';
|
|
||||||
import { Logger } from 'src/app/services/logger/main/service';
|
|
||||||
import { err, Result } from 'neverthrow';
|
|
||||||
import { MessageMapper } from '../../mapper/messageMapper';
|
|
||||||
import { RoomType } from "src/app/core/chat/entity/group";
|
|
||||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
|
||||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
|
||||||
import { MessageAttachmentFileType, MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
|
||||||
import { IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
|
|
||||||
import { IMessageSocketRepository } from 'src/app/core/chat/repository/message/message-socket-repository';
|
|
||||||
import { IMemberLocalRepository } from 'src/app/core/chat/repository/member/member-local-repository';
|
|
||||||
import { IAttachmentLocalRepository } from 'src/app/core/chat/repository/typing/typing-local-repository';
|
|
||||||
import { base64Schema } from 'src/app/utils/zod';
|
|
||||||
|
|
||||||
|
|
||||||
export const MessageInputDTOSchema = z.object({
|
|
||||||
roomId: z.string().uuid().optional(),
|
|
||||||
receiverId: z.number().optional(),
|
|
||||||
senderId: z.number(),
|
|
||||||
message: z.string().nullable().optional(),
|
|
||||||
messageType: z.number(),
|
|
||||||
canEdit: z.boolean(),
|
|
||||||
oneShot: z.boolean(),
|
|
||||||
requireUnlock: z.boolean(),
|
|
||||||
requestId: z.string(),
|
|
||||||
attachment: z.object({
|
|
||||||
fileType: z.nativeEnum(MessageAttachmentFileType),
|
|
||||||
source: z.nativeEnum(MessageAttachmentSource),
|
|
||||||
file: base64Schema.optional(),
|
|
||||||
fileName: z.string().optional(),
|
|
||||||
applicationId: z.number().optional(),
|
|
||||||
docId: z.number().optional(),
|
|
||||||
mimeType: z.string().nullable().optional(),
|
|
||||||
description: z.string().optional()
|
|
||||||
}).optional()
|
|
||||||
});
|
|
||||||
export type MessageInputDTO = z.infer<typeof MessageInputDTOSchema>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const MessageCreatePutDataDTOSchema = z.object({
|
|
||||||
id: z.string(),
|
|
||||||
roomId: z.string(),
|
|
||||||
sender: z.object({
|
|
||||||
wxUserId: z.number(),
|
|
||||||
wxFullName: z.string(),
|
|
||||||
wxeMail: z.string(),
|
|
||||||
userPhoto: z.string().optional()
|
|
||||||
}),
|
|
||||||
message: z.string().nullable().optional(),
|
|
||||||
messageType: z.number(),
|
|
||||||
sentAt: z.string(),
|
|
||||||
canEdit: z.boolean(),
|
|
||||||
oneShot: z.boolean(),
|
|
||||||
requireUnlock: z.boolean(),
|
|
||||||
requestId: z.string().optional().nullable(),
|
|
||||||
reactions: z.object({
|
|
||||||
id: z.string(),
|
|
||||||
reactedAt: z.string(),
|
|
||||||
reaction: z.string(),
|
|
||||||
sender: z.object({}),
|
|
||||||
}).array(),
|
|
||||||
info: z.array(z.object({
|
|
||||||
memberId: z.number(),
|
|
||||||
readAt: z.string().nullable(),
|
|
||||||
deliverAt: z.string().nullable()
|
|
||||||
})),
|
|
||||||
attachments: z.array(z.object({
|
|
||||||
fileType: z.nativeEnum(MessageAttachmentFileType),
|
|
||||||
source: z.nativeEnum(MessageAttachmentSource),
|
|
||||||
file: z.string().optional(),
|
|
||||||
fileName: z.string().optional(),
|
|
||||||
applicationId: z.number().optional(),
|
|
||||||
docId: z.number().optional(),
|
|
||||||
id: z.string().optional()
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
|
|
||||||
export type MessageCreateOutPutDataDTO = z.infer<typeof MessageCreatePutDataDTOSchema>
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class MessageCreateUseCaseService {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private AttachmentLocalRepositoryService: IAttachmentLocalRepository,
|
|
||||||
private messageLocalDataSourceService: IMessageLocalRepository,
|
|
||||||
private messageSocketRepositoryService: IMessageSocketRepository,
|
|
||||||
private MemberListLocalRepository: IMemberLocalRepository
|
|
||||||
) { }
|
|
||||||
|
|
||||||
|
|
||||||
@XTracerAsync({name:'MessageCreateUseCaseService', module:'chat', bugPrint: true, waitNThrow: 5000})
|
|
||||||
async execute(message: IMessage, messageEnum: RoomType, tracing?: TracingType) {
|
|
||||||
|
|
||||||
const validation = zodSafeValidation<IMessage>(MessageEntitySchema, message)
|
|
||||||
|
|
||||||
if(validation.isOk()) {
|
|
||||||
message.sendAttemp++;
|
|
||||||
|
|
||||||
message.requestId = uuidv4();
|
|
||||||
message.sending = true;
|
|
||||||
|
|
||||||
const createMessageLocally = this.messageLocalDataSourceService.insert(message)
|
|
||||||
|
|
||||||
createMessageLocally.then(async (value) => {
|
|
||||||
if(value.isOk()) {
|
|
||||||
|
|
||||||
const localId = value.value
|
|
||||||
message.$id = localId
|
|
||||||
|
|
||||||
if(message.hasAttachment) {
|
|
||||||
|
|
||||||
for (const attachment of message.attachments) {
|
|
||||||
|
|
||||||
if(attachment.source != MessageAttachmentSource.Webtrix) {
|
|
||||||
|
|
||||||
this.AttachmentLocalRepositoryService.insert({
|
|
||||||
$messageId: localId,
|
|
||||||
file: createBlobFromBase64(attachment.file, attachment.mimeType),
|
|
||||||
fileType: attachment.fileType,
|
|
||||||
source: attachment.source,
|
|
||||||
fileName: attachment.fileName,
|
|
||||||
applicationId: attachment.applicationId,
|
|
||||||
docId: attachment.docId,
|
|
||||||
mimeType: attachment.mimeType,
|
|
||||||
base64: createDataURL(attachment.file, attachment.mimeType)
|
|
||||||
}).then((e) => {
|
|
||||||
if(e.isErr()) {
|
|
||||||
Logger.error('failed to create attachment locally on send message', {
|
|
||||||
error: e.error,
|
|
||||||
data: createDataURL(attachment.file, attachment.mimeType).slice(0, 100) +'...'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
attachment.safeFile = createDataURL(attachment.file, attachment.mimeType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Logger.error('failed to insert locally', {
|
|
||||||
error: value.error.message
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch((error) => {
|
|
||||||
Logger.error('failed to insert catch', {
|
|
||||||
//error: createMessageLocally.error.message
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
let sendMessageResult: Result<MessageOutPutDataDTO, any>
|
|
||||||
|
|
||||||
if(messageEnum == RoomType.Group) {
|
|
||||||
const DTO = MessageMapper.fromDomain(message, message.requestId)
|
|
||||||
message.sending = true
|
|
||||||
sendMessageResult = await this.messageSocketRepositoryService.sendGroupMessage(DTO)
|
|
||||||
} else {
|
|
||||||
const DTO = MessageMapper.fromDomain(message, message.requestId)
|
|
||||||
delete DTO.roomId
|
|
||||||
message.sending = true
|
|
||||||
sendMessageResult = await this.messageSocketRepositoryService.sendDirectMessage(DTO)
|
|
||||||
}
|
|
||||||
|
|
||||||
// return this sendMessageResult
|
|
||||||
|
|
||||||
if(sendMessageResult.isOk()) {
|
|
||||||
|
|
||||||
message.id = sendMessageResult.value.id
|
|
||||||
|
|
||||||
console.log('sendMessageResult', sendMessageResult.value.id)
|
|
||||||
|
|
||||||
if(sendMessageResult.value.sender == undefined || sendMessageResult.value.sender == null) {
|
|
||||||
|
|
||||||
delete sendMessageResult.value.sender
|
|
||||||
}
|
|
||||||
|
|
||||||
let clone: MessageTable = {
|
|
||||||
...sendMessageResult.value,
|
|
||||||
id: sendMessageResult.value.id,
|
|
||||||
$id : message.$id
|
|
||||||
}
|
|
||||||
|
|
||||||
createMessageLocally.then(() => {
|
|
||||||
this.messageLocalDataSourceService.update(message.$id, {...clone, sending: false, roomId: clone.roomId}).then((data)=> {
|
|
||||||
if(data.isOk()) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
tracing.hasError('failed to update send message')
|
|
||||||
console.log(sendMessageResult)
|
|
||||||
console.log(data.error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return sendMessageResult
|
|
||||||
} else {
|
|
||||||
Logger.error('failed to send message to the server', {
|
|
||||||
error: sendMessageResult.error
|
|
||||||
})
|
|
||||||
await this.messageLocalDataSourceService.update(message.$id, {sending: false, $id: message.$id})
|
|
||||||
return err('no connection')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if(validation.error.formErrors.fieldErrors.attachments) {
|
|
||||||
Logger.error('failed to send message doe to invalid attachment', {
|
|
||||||
zodErrorList: validation.error.errors,
|
|
||||||
data: message.attachments
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Logger.error('failed to send message, validation failed', {
|
|
||||||
zodErrorList: validation.error.errors,
|
|
||||||
data: message
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,8 @@ import { IMessageLocalRepository } from 'src/app/core/chat/repository/message/me
|
|||||||
import { IMessageSocketRepository } from 'src/app/core/chat/repository/message/message-socket-repository';
|
import { IMessageSocketRepository } from 'src/app/core/chat/repository/message/message-socket-repository';
|
||||||
import { IMemberLocalRepository } from 'src/app/core/chat/repository/member/member-local-repository';
|
import { IMemberLocalRepository } from 'src/app/core/chat/repository/member/member-local-repository';
|
||||||
import { IAttachmentLocalRepository } from 'src/app/core/chat/repository/typing/typing-local-repository';
|
import { IAttachmentLocalRepository } from 'src/app/core/chat/repository/typing/typing-local-repository';
|
||||||
import { base64Schema } from 'src/app/utils/zod';
|
import { IMessageRemoteRepository } from '../../repository/message/message-remote-repository';
|
||||||
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
|
||||||
|
|
||||||
export const MessageInputDTOSchema = z.object({
|
export const MessageInputDTOSchema = z.object({
|
||||||
@@ -28,16 +29,7 @@ export const MessageInputDTOSchema = z.object({
|
|||||||
oneShot: z.boolean(),
|
oneShot: z.boolean(),
|
||||||
requireUnlock: z.boolean(),
|
requireUnlock: z.boolean(),
|
||||||
requestId: z.string(),
|
requestId: z.string(),
|
||||||
attachment: z.object({
|
attachment: z.string().array(),
|
||||||
fileType: z.nativeEnum(MessageAttachmentFileType),
|
|
||||||
source: z.nativeEnum(MessageAttachmentSource),
|
|
||||||
file: base64Schema.optional(),
|
|
||||||
fileName: z.string().optional(),
|
|
||||||
applicationId: z.number().optional(),
|
|
||||||
docId: z.number().optional(),
|
|
||||||
mimeType: z.string().nullable().optional(),
|
|
||||||
description: z.string().optional()
|
|
||||||
}).array(),
|
|
||||||
deviceId: z.string().optional()
|
deviceId: z.string().optional()
|
||||||
});
|
});
|
||||||
export type MessageInputDTO = z.infer<typeof MessageInputDTOSchema>
|
export type MessageInputDTO = z.infer<typeof MessageInputDTOSchema>
|
||||||
@@ -71,15 +63,7 @@ export const MessageCreatePutDataDTOSchema = z.object({
|
|||||||
readAt: z.string().nullable(),
|
readAt: z.string().nullable(),
|
||||||
deliverAt: z.string().nullable()
|
deliverAt: z.string().nullable()
|
||||||
})),
|
})),
|
||||||
attachments: z.array(z.object({
|
attachments: z.array(z.string())
|
||||||
fileType: z.nativeEnum(MessageAttachmentFileType),
|
|
||||||
source: z.nativeEnum(MessageAttachmentSource),
|
|
||||||
file: z.string().optional(),
|
|
||||||
fileName: z.string().optional(),
|
|
||||||
applicationId: z.number().optional(),
|
|
||||||
docId: z.number().optional(),
|
|
||||||
id: z.string().optional()
|
|
||||||
}))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type MessageCreateOutPutDataDTO = z.infer<typeof MessageCreatePutDataDTOSchema>
|
export type MessageCreateOutPutDataDTO = z.infer<typeof MessageCreatePutDataDTOSchema>
|
||||||
@@ -93,7 +77,8 @@ export class MessageCreateUseCaseService {
|
|||||||
private AttachmentLocalRepositoryService: IAttachmentLocalRepository,
|
private AttachmentLocalRepositoryService: IAttachmentLocalRepository,
|
||||||
private messageLocalDataSourceService: IMessageLocalRepository,
|
private messageLocalDataSourceService: IMessageLocalRepository,
|
||||||
private messageSocketRepositoryService: IMessageSocketRepository,
|
private messageSocketRepositoryService: IMessageSocketRepository,
|
||||||
private MemberListLocalRepository: IMemberLocalRepository
|
private MemberListLocalRepository: IMemberLocalRepository,
|
||||||
|
private MessageRemoteRepository: IMessageRemoteRepository
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|
||||||
@@ -105,54 +90,74 @@ export class MessageCreateUseCaseService {
|
|||||||
if(validation.isOk()) {
|
if(validation.isOk()) {
|
||||||
message.sendAttemp++;
|
message.sendAttemp++;
|
||||||
|
|
||||||
const createMessageLocally = this.messageLocalDataSourceService.insert(message)
|
const createMessageLocally = await this.messageLocalDataSourceService.insert(message)
|
||||||
|
|
||||||
createMessageLocally.then((value) => {
|
if(createMessageLocally.isOk()) {
|
||||||
if(value.isOk()) {
|
|
||||||
|
|
||||||
message.$id = value.value
|
message.$id = createMessageLocally.value
|
||||||
|
|
||||||
if(message.hasAttachment) {
|
if(message.hasAttachment) {
|
||||||
|
|
||||||
for (const attachment of message.attachments) {
|
for (const attachment of message.attachments) {
|
||||||
|
const isWebtrix = attachment.source === MessageAttachmentSource.Webtrix;
|
||||||
|
|
||||||
if(attachment.source != MessageAttachmentSource.Webtrix) {
|
await this.AttachmentLocalRepositoryService.insert({
|
||||||
|
$messageId: createMessageLocally.value,
|
||||||
this.AttachmentLocalRepositoryService.insert({
|
file: isWebtrix ? null : createBlobFromBase64(attachment.file || '', attachment.mimeType),
|
||||||
$messageId: value.value,
|
|
||||||
file: createBlobFromBase64(attachment.file, attachment.mimeType),
|
|
||||||
fileType: attachment.fileType,
|
fileType: attachment.fileType,
|
||||||
source: attachment.source,
|
source: attachment.source,
|
||||||
fileName: attachment.fileName,
|
fileName: attachment.fileName,
|
||||||
applicationId: attachment.applicationId,
|
applicationId: attachment.applicationId,
|
||||||
docId: attachment.docId,
|
docId: attachment.docId,
|
||||||
mimeType: attachment.mimeType,
|
mimeType: attachment.mimeType,
|
||||||
base64: createDataURL(attachment.file, attachment.mimeType)
|
base64: isWebtrix ? null : createDataURL(attachment.file || '', attachment.mimeType),
|
||||||
|
id: null,
|
||||||
}).then((e) => {
|
}).then((e) => {
|
||||||
if(e.isErr()) {
|
if(e.isErr()) {
|
||||||
Logger.error('failed to create attachment locally on send message', {
|
Logger.error('failed to create attachment locally on send message', {
|
||||||
error: e.error,
|
error: e.error,
|
||||||
data: createDataURL(attachment.file, attachment.mimeType).slice(0, 100) +'...'
|
data: !isWebtrix ? createDataURL(attachment.file, attachment.mimeType).slice(0, 100) +'...' : undefined
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
if(!isWebtrix) {
|
||||||
attachment.safeFile = createDataURL(attachment.file, attachment.mimeType)
|
attachment.safeFile = createDataURL(attachment.file, attachment.mimeType)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var attachments = await this.AttachmentLocalRepositoryService.find({
|
||||||
} else {
|
$messageId: createMessageLocally.value,
|
||||||
Logger.error('failed to insert locally', {
|
|
||||||
error: value.error.message
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(attachments.isOk()) {
|
||||||
|
var i = 0;
|
||||||
|
for (const att of attachments.value) {
|
||||||
|
|
||||||
|
const isWebtrix = att.source === MessageAttachmentSource.Webtrix;
|
||||||
|
var a = await this.MessageRemoteRepository.messageAttachmentUpload({
|
||||||
|
fileType: att.fileType,
|
||||||
|
source: att.source,
|
||||||
|
file: isWebtrix ? null : att.base64.replace(/^data:[a-zA-Z]+\/[a-zA-Z]+;base64,/, ''),
|
||||||
|
fileName: att.fileName,
|
||||||
|
applicationId: att.applicationId || 0,
|
||||||
|
docId: att.docId || 0,
|
||||||
|
mimeType: att.mimeType,
|
||||||
|
description: att.description || "something",
|
||||||
|
senderId: SessionStore.user.UserId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if(a.isOk()) {
|
||||||
|
att.id = a.value as string;
|
||||||
|
message.attachments[i].id = a.value as string;
|
||||||
|
await this.AttachmentLocalRepositoryService.update(att.$id, att)
|
||||||
|
} else {
|
||||||
|
return err('failed to upload attachment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//====================
|
//====================
|
||||||
message.sending = true
|
message.sending = true
|
||||||
|
|
||||||
@@ -172,7 +177,6 @@ export class MessageCreateUseCaseService {
|
|||||||
|
|
||||||
tracing.setAttribute("duration", `Execution time: ${duration}ms`);
|
tracing.setAttribute("duration", `Execution time: ${duration}ms`);
|
||||||
|
|
||||||
// return this sendMessageResult
|
|
||||||
|
|
||||||
if(sendMessageResult.isOk()) {
|
if(sendMessageResult.isOk()) {
|
||||||
|
|
||||||
@@ -185,14 +189,14 @@ export class MessageCreateUseCaseService {
|
|||||||
delete sendMessageResult.value.sender
|
delete sendMessageResult.value.sender
|
||||||
}
|
}
|
||||||
|
|
||||||
createMessageLocally.then((value) => {
|
|
||||||
console.log('sendMessageResult', (sendMessageResult as any).value)
|
console.log('sendMessageResult', (sendMessageResult as any).value)
|
||||||
let clone: MessageTable = {
|
let clone: MessageTable = {
|
||||||
...(sendMessageResult as any).value,
|
...(sendMessageResult as any).value,
|
||||||
id: (sendMessageResult as any).value.id,
|
id: (sendMessageResult as any).value.id,
|
||||||
$id : message.$id
|
$id : message.$id
|
||||||
}
|
}
|
||||||
console.log('set update')
|
|
||||||
this.messageLocalDataSourceService.update(message.$id, {...clone, sending: false, roomId: clone.roomId}).then((data)=> {
|
this.messageLocalDataSourceService.update(message.$id, {...clone, sending: false, roomId: clone.roomId}).then((data)=> {
|
||||||
if(data.isOk()) {
|
if(data.isOk()) {
|
||||||
|
|
||||||
@@ -202,7 +206,6 @@ export class MessageCreateUseCaseService {
|
|||||||
console.log(data.error)
|
console.log(data.error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return sendMessageResult
|
return sendMessageResult
|
||||||
@@ -213,21 +216,8 @@ export class MessageCreateUseCaseService {
|
|||||||
await this.messageLocalDataSourceService.update(message.$id, {sending: false, $id: message.$id})
|
await this.messageLocalDataSourceService.update(message.$id, {sending: false, $id: message.$id})
|
||||||
return err('no connection')
|
return err('no connection')
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
if(validation.error.formErrors.fieldErrors.attachments) {
|
|
||||||
Logger.error('failed to send message doe to invalid attachment', {
|
|
||||||
zodErrorList: validation.error.errors,
|
|
||||||
data: message.attachments
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Logger.error('failed to send message, validation failed', {
|
|
||||||
zodErrorList: validation.error.errors,
|
|
||||||
data: message
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,16 +6,18 @@ import { v4 as uuidv4 } from 'uuid'
|
|||||||
import { AttachmentLocalDataSource } from '../../../../module/chat/data/repository/attachment/attachment-local-repository.service';
|
import { AttachmentLocalDataSource } from '../../../../module/chat/data/repository/attachment/attachment-local-repository.service';
|
||||||
import { RoomLocalRepository } from '../../../../module/chat/data/repository/room/room-local-repository.service';
|
import { RoomLocalRepository } from '../../../../module/chat/data/repository/room/room-local-repository.service';
|
||||||
import { MemberListLocalRepository } from 'src/app/module/chat/data/repository/member/member-list-local-repository.service'
|
import { MemberListLocalRepository } from 'src/app/module/chat/data/repository/member/member-list-local-repository.service'
|
||||||
import { Result } from 'neverthrow';
|
import { err, Result } from 'neverthrow';
|
||||||
import { RoomType } from 'src/app/core/chat/entity/group';
|
import { RoomType } from 'src/app/core/chat/entity/group';
|
||||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||||
import { MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
import { MessageAttachmentSource, MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
||||||
import { IDBoolean } from 'src/app/infra/database/dexie/type';
|
import { IDBoolean } from 'src/app/infra/database/dexie/type';
|
||||||
import { IMemberLocalRepository } from '../../repository/member/member-local-repository';
|
import { IMemberLocalRepository } from '../../repository/member/member-local-repository';
|
||||||
import { IMessageLocalRepository } from '../../repository/message/message-local-repository';
|
import { IMessageLocalRepository } from '../../repository/message/message-local-repository';
|
||||||
import { IMessageSocketRepository } from '../../repository/message/message-socket-repository';
|
import { IMessageSocketRepository } from '../../repository/message/message-socket-repository';
|
||||||
import { IRoomLocalRepository } from '../../repository/room/room-local-repository';
|
import { IRoomLocalRepository } from '../../repository/room/room-local-repository';
|
||||||
import { IAttachmentLocalRepository } from '../../repository/typing/typing-local-repository';
|
import { IAttachmentLocalRepository } from '../../repository/typing/typing-local-repository';
|
||||||
|
import { IMessageRemoteRepository } from '../../repository/message/message-remote-repository';
|
||||||
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -29,6 +31,8 @@ export class SendLocalMessagesUseCaseService {
|
|||||||
private roomLocalDataSourceService: IRoomLocalRepository,
|
private roomLocalDataSourceService: IRoomLocalRepository,
|
||||||
private MemberListLocalRepository: IMemberLocalRepository,
|
private MemberListLocalRepository: IMemberLocalRepository,
|
||||||
private messageSocketRepositoryService: IMessageSocketRepository,
|
private messageSocketRepositoryService: IMessageSocketRepository,
|
||||||
|
private MessageRemoteRepository: IMessageRemoteRepository,
|
||||||
|
private AttachmentLocalRepositoryService: IAttachmentLocalRepository,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
async execute() {
|
async execute() {
|
||||||
@@ -53,7 +57,12 @@ export class SendLocalMessagesUseCaseService {
|
|||||||
|
|
||||||
if(attachments.isOk()) {
|
if(attachments.isOk()) {
|
||||||
|
|
||||||
message.attachments = attachments.value.map(e => ({
|
message.attachments = attachments.value.map(e => {
|
||||||
|
const base64 = typeof e.base64 === "string"
|
||||||
|
? e.base64.replace(/^data:[a-zA-Z]+\/[a-zA-Z]+;base64,/, "")
|
||||||
|
: "";
|
||||||
|
|
||||||
|
return {
|
||||||
fileType: e.fileType,
|
fileType: e.fileType,
|
||||||
source: e.source,
|
source: e.source,
|
||||||
fileName: e.fileName,
|
fileName: e.fileName,
|
||||||
@@ -62,8 +71,35 @@ export class SendLocalMessagesUseCaseService {
|
|||||||
id: e.id,
|
id: e.id,
|
||||||
mimeType: e.mimeType,
|
mimeType: e.mimeType,
|
||||||
description: e.description,
|
description: e.description,
|
||||||
file: e.base64.split(',')[1]
|
file: base64
|
||||||
}))
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
for (const att of attachments.value) {
|
||||||
|
|
||||||
|
const isWebtrix = att.source === MessageAttachmentSource.Webtrix;
|
||||||
|
var a = await this.MessageRemoteRepository.messageAttachmentUpload({
|
||||||
|
fileType: att.fileType,
|
||||||
|
source: att.source,
|
||||||
|
file: isWebtrix ? null : att.base64.replace(/^data:[a-zA-Z]+\/[a-zA-Z]+;base64,/, ''),
|
||||||
|
fileName: att.fileName,
|
||||||
|
applicationId: att.applicationId || 0,
|
||||||
|
docId: att.docId || 0,
|
||||||
|
mimeType: att.mimeType,
|
||||||
|
description: att.description || "something",
|
||||||
|
senderId: SessionStore.user.UserId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if(a.isOk()) {
|
||||||
|
att.id = a.value as string;
|
||||||
|
message.attachments[i].id = a.value as string;
|
||||||
|
await this.AttachmentLocalRepositoryService.update(att.$id, att)
|
||||||
|
} else {
|
||||||
|
return err('failed to upload attachment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await this.messageLocalDataSourceService.update(message.$id, { sending: true })
|
await this.messageLocalDataSourceService.update(message.$id, { sending: true })
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
const SocketMessageCreateOutputSchema = MessageEntitySchema.pick({
|
const SocketMessageCreateOutputSchema = MessageEntitySchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
attachments: true,
|
|
||||||
canEdit: true,
|
canEdit: true,
|
||||||
editedAt: true,
|
editedAt: true,
|
||||||
info: true,
|
info: true,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { IMessageLocalRepository } from '../../repository/message/message-local-
|
|||||||
|
|
||||||
const SocketMessageDeleteOutputSchema = MessageEntitySchema.pick({
|
const SocketMessageDeleteOutputSchema = MessageEntitySchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
attachments: true,
|
|
||||||
canEdit: true,
|
canEdit: true,
|
||||||
editedAt: true,
|
editedAt: true,
|
||||||
info: true,
|
info: true,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { IMessageLocalRepository } from '../../repository/message/message-local-
|
|||||||
|
|
||||||
const SocketMessageUpdateOutputSchema = MessageEntitySchema.pick({
|
const SocketMessageUpdateOutputSchema = MessageEntitySchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
attachments: true,
|
|
||||||
canEdit: true,
|
canEdit: true,
|
||||||
editedAt: true,
|
editedAt: true,
|
||||||
info: true,
|
info: true,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { HttpErrorResponse } from "@angular/common/http";
|
import { HttpErrorResponse } from "@angular/common/http";
|
||||||
import { Result } from "neverthrow";
|
import { Result } from "neverthrow";
|
||||||
import { HttpResult } from "src/app/infra/http/type";
|
import { HttpResult } from "src/app/infra/http/type";
|
||||||
import { UserLoginInput } from "../use-case/user-login-use-case.service";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import { UserPhotoUploadInput } from "../use-case/user-photo-upload.service";
|
||||||
|
|
||||||
const UserRepositoryLoginParams = z.object({
|
const UserRepositoryLoginParams = z.object({
|
||||||
Auth: z.string(),
|
Auth: z.string(),
|
||||||
@@ -55,4 +55,5 @@ export abstract class IUserRemoteRepository {
|
|||||||
abstract login(input: IUserRepositoryLoginParams): Promise<Result<HttpResult<UserLoginOutputResponse>, HttpErrorResponse>>
|
abstract login(input: IUserRepositoryLoginParams): Promise<Result<HttpResult<UserLoginOutputResponse>, HttpErrorResponse>>
|
||||||
abstract logout(): Promise<Result<HttpResult<any>, HttpErrorResponse>>
|
abstract logout(): Promise<Result<HttpResult<any>, HttpErrorResponse>>
|
||||||
abstract refreshToken(input:UserRefreshTokenInputDTO): Promise<Result<HttpResult<any>, HttpErrorResponse>>
|
abstract refreshToken(input:UserRefreshTokenInputDTO): Promise<Result<HttpResult<any>, HttpErrorResponse>>
|
||||||
|
abstract uploadPhoto(input: UserPhotoUploadInput): Promise<Result<HttpResult<any>, HttpErrorResponse>>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { UserLocalRepositoryService } from 'src/app/module/user/data/datasource/user-local-repository.service';
|
||||||
|
import { UserRemoteRepositoryService } from 'src/app/module/user/data/datasource/user-remote-repository.service';
|
||||||
|
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||||
import { z, ZodError, ZodSchema } from 'zod';
|
import { z, ZodError, ZodSchema } from 'zod';
|
||||||
|
|
||||||
const UserGetByIdInputSchema = z.object({
|
const UserGetByIdInputSchema = z.object({
|
||||||
@@ -35,5 +38,21 @@ export type UserGetByIdOutput = z.infer<typeof UserGetByIdOutputSchema>
|
|||||||
})
|
})
|
||||||
export class UserGetByIdService {
|
export class UserGetByIdService {
|
||||||
|
|
||||||
constructor() { }
|
constructor(
|
||||||
|
private remote: UserRemoteRepositoryService,
|
||||||
|
private local: UserLocalRepositoryService
|
||||||
|
) { }
|
||||||
|
|
||||||
|
async execute(guid: string , tracing?: TracingType) {
|
||||||
|
const result = await this.remote.getUserProfilePhoto(guid, tracing)
|
||||||
|
|
||||||
|
if(result.isOk()) {
|
||||||
|
this.local.addProfilePicture({base64: result.value.data.data.userPhoto})
|
||||||
|
} else {
|
||||||
|
tracing?.setAttribute("picture.upload", "false")
|
||||||
|
tracing?.hasError("cant upload picture")
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { IUserRemoteRepository } from '../repository/user-remote-repository';
|
||||||
|
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||||
|
import { UserLocalRepositoryService } from 'src/app/module/user/data/datasource/user-local-repository.service';
|
||||||
|
|
||||||
|
// Schema for photo validation
|
||||||
|
export const UserPhotoUploadInputSchema = z.object({
|
||||||
|
photo: z.string().regex(/^data:image\/[a-zA-Z]+;base64,/, {
|
||||||
|
message: 'Photo must start with data:image/...;base64,',
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserPhotoUploadInput = z.infer<typeof UserPhotoUploadInputSchema>;
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class UserPhotoUploadUseCase {
|
||||||
|
constructor(
|
||||||
|
private remote: IUserRemoteRepository,
|
||||||
|
private local: UserLocalRepositoryService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
@XTracerAsync({ name: 'UserLoginUseCaseService', module: 'user', bugPrint: true })
|
||||||
|
async execute(input: unknown, tracing?: TracingType) {
|
||||||
|
// ✅ Validate input with Zod
|
||||||
|
const parsed = UserPhotoUploadInputSchema.safeParse(input);
|
||||||
|
if (!parsed.success) {
|
||||||
|
tracing?.setAttribute("picture.upload", "false");
|
||||||
|
tracing?.hasError("invalid input: " + JSON.stringify(parsed.error.format()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const validInput = parsed.data;
|
||||||
|
|
||||||
|
const result = await this.remote.uploadPhoto(validInput);
|
||||||
|
|
||||||
|
if (result.isOk()) {
|
||||||
|
this.local.addProfilePicture({ base64: validInput.photo });
|
||||||
|
} else {
|
||||||
|
tracing?.setAttribute("picture.upload", "false");
|
||||||
|
tracing?.hasError("cant upload picture");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ export const AttachmentTableSchema = z.object({
|
|||||||
$id: z.number().optional(), // local id
|
$id: z.number().optional(), // local id
|
||||||
$messageId: z.string(),
|
$messageId: z.string(),
|
||||||
attachmentId: z.string().optional(),
|
attachmentId: z.string().optional(),
|
||||||
file: z.instanceof(Blob).optional(),
|
file: z.instanceof(Blob).nullable().optional(),
|
||||||
base64: zodDataUrlSchema.nullable().optional(),
|
base64: zodDataUrlSchema.nullable().optional(),
|
||||||
//
|
//
|
||||||
fileType: z.nativeEnum(MessageAttachmentFileType).optional(),
|
fileType: z.nativeEnum(MessageAttachmentFileType).optional(),
|
||||||
@@ -16,7 +16,7 @@ export const AttachmentTableSchema = z.object({
|
|||||||
applicationId: z.number().optional(),
|
applicationId: z.number().optional(),
|
||||||
docId: z.number().optional(),
|
docId: z.number().optional(),
|
||||||
mimeType: z.string().nullable().optional(),
|
mimeType: z.string().nullable().optional(),
|
||||||
id: z.string().uuid().optional(),
|
id: z.string().uuid().nullable().optional(),
|
||||||
description: z.string().optional()
|
description: z.string().optional()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -27,4 +27,19 @@ export class FilePickerWebService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getAnyFileFromDevice(): Promise<Result<File, any>> {
|
||||||
|
let input = document.createElement('input');
|
||||||
|
input.type = 'file';
|
||||||
|
|
||||||
|
input.click();
|
||||||
|
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
input.onchange = async () => {
|
||||||
|
const file = Array.from(input.files)
|
||||||
|
resolve(ok(file[0] as File));
|
||||||
|
};
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { UserRepositoryService } from 'src/app/module/user/data/user-repository.
|
|||||||
import { isHttpError } from 'src/app/services/http.service';
|
import { isHttpError } from 'src/app/services/http.service';
|
||||||
import { UserProfilePicture } from 'src/app/module/user/data/datasource/user-local-repository.service';
|
import { UserProfilePicture } from 'src/app/module/user/data/datasource/user-local-repository.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { UserPhotoUploadUseCase } from 'src/app/core/user/use-case/user-photo-upload.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-edit-profile',
|
selector: 'app-edit-profile',
|
||||||
@@ -43,8 +44,8 @@ export class EditProfilePage implements OnInit {
|
|||||||
private CameraService: CameraService,
|
private CameraService: CameraService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private httpErrorHandle: HttpErrorHandle,
|
private httpErrorHandle: HttpErrorHandle,
|
||||||
private UserRepositoryService: UserRepositoryService
|
private UserRepositoryService: UserRepositoryService,
|
||||||
|
private UserPhotoUploadUseCase: UserPhotoUploadUseCase
|
||||||
) {
|
) {
|
||||||
this.profilePictureSubject = this.UserRepositoryService.getProfilePictureLive() as any
|
this.profilePictureSubject = this.UserRepositoryService.getProfilePictureLive() as any
|
||||||
}
|
}
|
||||||
@@ -178,33 +179,29 @@ export class EditProfilePage implements OnInit {
|
|||||||
if(capturedImage.isOk()) {
|
if(capturedImage.isOk()) {
|
||||||
|
|
||||||
this.capturedImage = capturedImage.value;
|
this.capturedImage = capturedImage.value;
|
||||||
var object = {
|
|
||||||
"ImageBase64": this.capturedImage
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing.addEvent('serialize image')
|
console.log(this.capturedImage);
|
||||||
|
|
||||||
const guid = await this.UserRepositoryService.addUserProfilePhoto(object)
|
var guid = await this.UserPhotoUploadUseCase.execute({photo: 'data:image/jpeg;base64,' +this.capturedImage}, tracing)
|
||||||
|
|
||||||
|
|
||||||
if(guid.isOk()) {
|
if(guid.isOk()) {
|
||||||
tracing.addEvent('upload image')
|
|
||||||
|
|
||||||
const base = await this.UserRepositoryService.getUserProfilePhoto(guid.value, tracing)
|
// const base = await this.UserRepositoryService.getUserProfilePhoto(guid.value, tracing)
|
||||||
|
|
||||||
if(base.isOk()) {
|
// if(base.isOk()) {
|
||||||
tracing.addEvent('download image')
|
// tracing.addEvent('download image')
|
||||||
this.profilePicture = 'data:image/jpeg;base64,' + base.value;
|
// this.profilePicture = 'data:image/jpeg;base64,' + base.value;
|
||||||
|
|
||||||
tracing.setAttribute("picture.save", "true")
|
// tracing.setAttribute("picture.save", "true")
|
||||||
|
|
||||||
} else {
|
// } else {
|
||||||
if(!isHttpError(base.error)) {
|
// if(!isHttpError(base.error)) {
|
||||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.')
|
// this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.')
|
||||||
} else {
|
// } else {
|
||||||
this.httpErrorHandle.httpStatusHandle(base.error)
|
// this.httpErrorHandle.httpStatusHandle(base.error)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(!isHttpError(guid.error)) {
|
if(!isHttpError(guid.error)) {
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import { environment } from 'src/environments/environment';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AttachmentRemoteDataSourceService implements IAttachmentRemoteRepository {
|
export class AttachmentRemoteDataSourceService implements IAttachmentRemoteRepository {
|
||||||
private baseUrl = `${environment.apiURLStage.slice(0, -1)}`; // Your base URL
|
private baseUrl = `${environment.apiURLStage}chat`; // Your base URL
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ export class MessageSocketRepositoryService implements IMessageSocketRepository
|
|||||||
data['requestId'] = uuidv4();
|
data['requestId'] = uuidv4();
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.socket.sendData<MessageCreateOutPutDataDTO>({
|
const result = await this.socket.sendData<MessageOutPutDataDTO>({
|
||||||
method: 'sendMessage',
|
method: 'sendMessage',
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import { HttpErrorResponse } from '@angular/common/http';
|
|||||||
import { Result } from 'neverthrow';
|
import { Result } from 'neverthrow';
|
||||||
import { HttpResult } from 'src/app/infra/http/type';
|
import { HttpResult } from 'src/app/infra/http/type';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
|
import { MessageAttachmentInput } from 'src/app/core/chat/usecase/message/message-attachment-upload-use-case.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class MessageRemoteDataSourceService implements IMessageRemoteRepository {
|
export class MessageRemoteDataSourceService {
|
||||||
|
|
||||||
private baseUrl = `${environment.apiURLStage}Chat`; // Your base URL
|
private baseUrl = `${environment.apiURLStage}Chat`; // Your base URL
|
||||||
|
|
||||||
@@ -23,6 +24,13 @@ export class MessageRemoteDataSourceService implements IMessageRemoteRepository
|
|||||||
private http: HttpAdapter
|
private http: HttpAdapter
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
async messageAttachmentUpload(input: MessageAttachmentInput) {
|
||||||
|
var a = await this.http.post<IMessageGetAllByRoomIdOutPut>(`${this.baseUrl}/attachment`, input)
|
||||||
|
return a.map((e) => {
|
||||||
|
return e.data.data["attachmentId"] as String
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||||
async getMessagesFromRoom(input: IGetMessagesFromRoomParams): DataSourceReturn<IMessageGetAllByRoomIdOutPut> {
|
async getMessagesFromRoom(input: IGetMessagesFromRoomParams): DataSourceReturn<IMessageGetAllByRoomIdOutPut> {
|
||||||
|
|||||||
@@ -2,17 +2,20 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpService } from 'src/app/services/http.service';
|
import { HttpService } from 'src/app/services/http.service';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { IProfilePictureInputDTO } from '../dto/profilePictureInputDTO';
|
import { IProfilePictureInputDTO } from '../dto/profilePictureInputDTO';
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
||||||
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
|
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||||
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
||||||
import { IUserRepositoryLoginParams, UserRefreshTokenInputDTO } from 'src/app/core/user/repository/user-remote-repository';
|
import { IUserRemoteRepository, IUserRepositoryLoginParams, UserLoginOutputResponse, UserRefreshTokenInputDTO } from 'src/app/core/user/repository/user-remote-repository';
|
||||||
import { UserLoginOutput } from 'src/app/core/user/use-case/user-login-use-case.service';
|
import { UserLoginOutput } from 'src/app/core/user/use-case/user-login-use-case.service';
|
||||||
import { SessionStore } from 'src/app/store/session.service';
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
import { UserGetByIdOutput } from 'src/app/core/user/use-case/user-get-by-id.service';
|
import { UserGetByIdOutput } from 'src/app/core/user/use-case/user-get-by-id.service';
|
||||||
|
import { Result } from 'neverthrow';
|
||||||
|
import { UserPhotoUploadInput } from 'src/app/core/user/use-case/user-photo-upload.service';
|
||||||
|
import { HttpResult } from 'src/app/infra/http/type';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class UserRemoteRepositoryService {
|
export class UserRemoteRepositoryService implements IUserRemoteRepository{
|
||||||
|
|
||||||
private baseUrl = `${environment.apiURLStage.slice(0, -1)}`; // Your base URL
|
private baseUrl = `${environment.apiURLStage.slice(0, -1)}`; // Your base URL
|
||||||
|
|
||||||
@@ -21,11 +24,13 @@ export class UserRemoteRepositoryService {
|
|||||||
private http: HttpAdapter,
|
private http: HttpAdapter,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
async uploadPhoto(input: UserPhotoUploadInput): Promise<Result<HttpResult<any>, HttpErrorResponse>> {
|
||||||
|
return await this.http.post<UserGetByIdOutput>(`${this.baseUrl}/Users/${SessionStore.user.UserId}/photo`, input)
|
||||||
|
}
|
||||||
|
|
||||||
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||||
async login(input: IUserRepositoryLoginParams) {
|
async login(input: IUserRepositoryLoginParams) {
|
||||||
|
return await this.http.post<UserLoginOutputResponse>(`${this.baseUrl}/Users/login`, input)
|
||||||
return await this.http.post<UserLoginOutput>(`${this.baseUrl}/Users/login`, input)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||||
@@ -43,17 +48,4 @@ export class UserRemoteRepositoryService {
|
|||||||
return await this.http.get<UserGetByIdOutput>(`${this.baseUrl}/Users/${SessionStore.user.UserId}`, {})
|
return await this.http.get<UserGetByIdOutput>(`${this.baseUrl}/Users/${SessionStore.user.UserId}`, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
addUserProfilePhoto(data: IProfilePictureInputDTO) {
|
|
||||||
const geturl = environment.apiURL + 'UserAuthentication/AddPhoto';
|
|
||||||
|
|
||||||
let http = new HttpHeaders();
|
|
||||||
|
|
||||||
http = http.set('content-type', "application/json");
|
|
||||||
http = http.set('accept', "application/json");
|
|
||||||
let options = {
|
|
||||||
headers: http
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.httpService.post<string>(`${geturl}`, data, options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,20 +27,6 @@ export class UserRepositoryService {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
async addUserProfilePhoto(data: IProfilePictureInputDTO, tracing?: TracingType) {
|
|
||||||
const result = await this.remote.addUserProfilePhoto(data)
|
|
||||||
|
|
||||||
|
|
||||||
if(result.isOk()) {
|
|
||||||
this.local.addProfilePicture({base64: 'data:image/jpeg;base64,' + data.ImageBase64})
|
|
||||||
} else {
|
|
||||||
tracing?.setAttribute("picture.upload", "false")
|
|
||||||
tracing?.hasError("cant upload picture")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
getProfilePictureLive() {
|
getProfilePictureLive() {
|
||||||
return this.local.getLiveProfilePicture()
|
return this.local.getLiveProfilePicture()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { ToastService } from 'src/app/services/toast.service';
|
|||||||
import { ZodError } from 'zod';
|
import { ZodError } from 'zod';
|
||||||
|
|
||||||
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service';
|
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service';
|
||||||
|
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -37,6 +38,7 @@ export class EditGroupPage implements OnInit {
|
|||||||
private httpErrorHandle: HttpErrorHandle,
|
private httpErrorHandle: HttpErrorHandle,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private chatServiceService: ChatServiceService,
|
private chatServiceService: ChatServiceService,
|
||||||
|
private RoomLocalDataSourceService: IRoomLocalRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -44,17 +46,13 @@ export class EditGroupPage implements OnInit {
|
|||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoomInfo(){
|
async getRoomInfo() {
|
||||||
// this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
const room = await this.RoomLocalDataSourceService.findOne({id:this.roomId})
|
||||||
// this.room = room['room'];
|
|
||||||
|
|
||||||
// try {
|
if(room.isOk()) {
|
||||||
// this.groupName = this.room.name.split('-').join(' ');
|
console.log(room.value);
|
||||||
// } catch (error) {
|
this.groupName = room.value.roomName;
|
||||||
// this.groupName = this.room.name;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
|||||||
@@ -876,7 +876,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
this.messages1[this.room.$id].push(message)
|
this.messages1[this.room.$id].push(message)
|
||||||
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
||||||
this.messageResult(sendMessage)
|
//this.messageResult(sendMessage)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
@@ -911,7 +911,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 100)
|
}, 100)
|
||||||
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
||||||
this.messageResult(sendMessage)
|
//this.messageResult(sendMessage)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1096,7 +1096,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 100)
|
}, 100)
|
||||||
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
||||||
this.messageResult(sendMessage)
|
//this.messageResult(sendMessage)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,7 +1154,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 100)
|
}, 100)
|
||||||
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
||||||
this.messageResult(sendMessage)
|
//this.messageResult(sendMessage)
|
||||||
this.textField = ''
|
this.textField = ''
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1242,7 +1242,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 100)
|
}, 100)
|
||||||
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
||||||
this.messageResult(sendMessage)
|
//this.messageResult(sendMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1266,7 +1266,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
const fileExtension = await allowedDocExtension(file.value.type)
|
const fileExtension = await allowedDocExtension(file.value.type)
|
||||||
|
|
||||||
if(fileExtension.isOk()) {
|
//if(fileExtension.isOk()) {
|
||||||
|
|
||||||
console.log('FILE rigth?', file)
|
console.log('FILE rigth?', file)
|
||||||
|
|
||||||
@@ -1297,12 +1297,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 100)
|
}, 100)
|
||||||
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
|
||||||
this.messageResult(sendMessage)
|
//this.messageResult(sendMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
//} else {
|
||||||
this.toastService._badRequest("Ficheiro inválido")
|
//this.toastService._badRequest("Ficheiro inválido")
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
|
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ModalController, NavParams, PickerController } from '@ionic/angular';
|
import { ModalController, NavParams, PickerController } from '@ionic/angular';
|
||||||
|
import { IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
|
||||||
|
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||||
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service';
|
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service';
|
||||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||||
import { ThemeService } from 'src/app/services/theme.service'
|
import { ThemeService } from 'src/app/services/theme.service'
|
||||||
@@ -18,7 +20,6 @@ export class EditGroupPage implements OnInit {
|
|||||||
showDuration: boolean;
|
showDuration: boolean;
|
||||||
selectedDuration = ['','',''];
|
selectedDuration = ['','',''];
|
||||||
groupName:string;
|
groupName:string;
|
||||||
room:any;
|
|
||||||
roomId:string;
|
roomId:string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -29,6 +30,7 @@ export class EditGroupPage implements OnInit {
|
|||||||
private httpErrorHandle: HttpErrorHandle,
|
private httpErrorHandle: HttpErrorHandle,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private chatServiceService: ChatServiceService,
|
private chatServiceService: ChatServiceService,
|
||||||
|
private RoomLocalDataSourceService: IRoomLocalRepository,
|
||||||
) {
|
) {
|
||||||
this.roomId = this.navParams.get('roomId');
|
this.roomId = this.navParams.get('roomId');
|
||||||
}
|
}
|
||||||
@@ -38,8 +40,13 @@ export class EditGroupPage implements OnInit {
|
|||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoomInfo(){
|
async getRoomInfo() {
|
||||||
|
const room = await this.RoomLocalDataSourceService.findOne({id:this.roomId})
|
||||||
|
|
||||||
|
if(room.isOk()) {
|
||||||
|
console.log(room.value);
|
||||||
|
this.groupName = room.value.roomName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(){
|
close(){
|
||||||
|
|||||||
@@ -562,6 +562,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
cssClass: 'modal modal-desktop',
|
cssClass: 'modal modal-desktop',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
roomId: this.RoomStore.room.id,
|
roomId: this.RoomStore.room.id,
|
||||||
|
currentName: this.RoomStore.room.roomName
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await modal.present();
|
await modal.present();
|
||||||
@@ -781,7 +782,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const file = await this.FilePickerWebService.getFileFromDevice(types)
|
const file = await this.FilePickerWebService.getAnyFileFromDevice();
|
||||||
|
|
||||||
if(file.isOk()) {
|
if(file.isOk()) {
|
||||||
|
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ export class RoomStore {
|
|||||||
|
|
||||||
this.messages1[this.room.$id].push(message)
|
this.messages1[this.room.$id].push(message)
|
||||||
let sendMessage = this.chatServiceService.sendMessage(message, this.room.roomType)
|
let sendMessage = this.chatServiceService.sendMessage(message, this.room.roomType)
|
||||||
this.messageResult(sendMessage)
|
//this.messageResult(sendMessage)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,212 +0,0 @@
|
|||||||
<div class="header-container header-fix" [ngClass]="{'d-none-header':HeaderSettingsService.hideHeader && ActiveTabService.pages.gabineteDetails}" >
|
|
||||||
<div class="main-tab pb-10 ion-toolbar header-color">
|
|
||||||
|
|
||||||
<div class="mobile pt-20 d-flex div-top-header justify-space-between">
|
|
||||||
|
|
||||||
<div title="Pesquisa" *ngIf="!hideSearchBtn" class="div-search viewport-font-size">
|
|
||||||
<div (click)="openSearch()" class="{{Cy.header.b.search}}">
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="font-45-em"
|
|
||||||
src="assets/images/theme/doneIt/icons-search.svg"></ion-icon>
|
|
||||||
<ion-icon *ngIf=" ThemeService.currentTheme == 'default' " class="font-45-em"
|
|
||||||
src='assets/images/icons-search.svg'></ion-icon>
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-45-em"
|
|
||||||
src='assets/images/theme/gov/icons-search.svg'></ion-icon>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="div-logo align-center justify-center">
|
|
||||||
<div class="logo-icon pr-10-rem">
|
|
||||||
<img *ngIf="ThemeService.currentTheme == 'default' " src='assets/images/logo-no-bg.png' alt='logo'>
|
|
||||||
<img *ngIf="ThemeService.currentTheme == 'gov' " src='assets/images/theme/gov/governoangola_A.png' alt='logo'>
|
|
||||||
<img *ngIf="ThemeService.currentTheme == 'doneIt'" src="assets/images/theme/doneIt/governoangola_A1.png"
|
|
||||||
alt='logo' />
|
|
||||||
</div>
|
|
||||||
<div *ngIf="ThemeService.currentTheme == 'gov'"
|
|
||||||
class="logo-description d-flex align-center justify-content-center">
|
|
||||||
<div class="logo-description-content">
|
|
||||||
<p class="logo-description-text tp-5">{{ environment.logoLabel }}</p>
|
|
||||||
|
|
||||||
<div class="add-line"></div>
|
|
||||||
<p class="logo-description-text tp-5">GABINETE DIGITAL</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="ThemeService.currentTheme == 'default' "
|
|
||||||
class="logo-description d-flex align-center justify-content-center">
|
|
||||||
<div class="logo-description-content">
|
|
||||||
<p class="logo-description-text tp-5 color-white">{{ environment.logoLabel }}</p>
|
|
||||||
<div class="add-line-white"></div>
|
|
||||||
<p class="logo-description-text tp-5 color-white">GABINETE DIGITAL</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div title="Perfil" class="div-profile cursor-pointer viewport-font-size " >
|
|
||||||
|
|
||||||
<div *ngIf="PublicationHolderService.count != 0" style="color: black" style="display: flex;
|
|
||||||
color: black;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
" >
|
|
||||||
<span *ngIf="!PublicationHolderService.PublicationFormMV?.[0]?.retry">{{ PublicationHolderService.count }}%</span>
|
|
||||||
<span style="padding-right: 12px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.PublicationFormMV?.[0]?.retryFunction()" ><ion-icon src="assets/images/retry-svgrepo-com.svg" > </ion-icon></span>
|
|
||||||
<span style="padding-right: 7px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.remove(PublicationHolderService.PublicationFormMV?.[0]?.id)">X</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div (click)="openProfile()" *ngIf="(profilePictureSubject | async) as calendarData" class="profile-image">
|
|
||||||
<img *ngIf="calendarData.base64 != null" class="profile-image image-prety" src={{calendarData.base64}}>
|
|
||||||
<ion-icon *ngIf="calendarData.base64 == null"
|
|
||||||
class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="profile-text" *ngIf="(notificationCount$ | async) as notificationCount ">
|
|
||||||
<div *ngIf="notificationCount > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
|
|
||||||
{{notificationCount}} </div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="desktop mx-20">
|
|
||||||
<div class="d-flex justify-space-between align-center">
|
|
||||||
<div tab="events" class="div-logo height-fit-content">
|
|
||||||
<div class="logo-icon pr-10-rem">
|
|
||||||
<img *ngIf="ThemeService.currentTheme == 'default'" src='assets/images/logo-no-bg.png' alt='logo'>
|
|
||||||
<img *ngIf="ThemeService.currentTheme == 'gov' " src='assets/images/theme/gov/governoangola_A.png'
|
|
||||||
alt='logo'>
|
|
||||||
<img *ngIf="ThemeService.currentTheme == 'doneIt' "
|
|
||||||
src='assets/images/theme/{{ThemeService.currentTheme}}/governoangola_A1.png' alt='logo'>
|
|
||||||
</div>
|
|
||||||
<div class="logo-description d-flex align-center justify-content-center">
|
|
||||||
|
|
||||||
<div class="logo-description-content">
|
|
||||||
|
|
||||||
<div *ngIf="ThemeService.currentTheme == 'gov' " class="logo-description-content">
|
|
||||||
|
|
||||||
<p class="logo-description-text">{{ environment.logoLabel }}</p>
|
|
||||||
<div class="add-line"></div>
|
|
||||||
<p class="logo-description-text">GABINETE DIGITAL</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="ThemeService.currentTheme == 'default' " class="logo-description-content">
|
|
||||||
|
|
||||||
<p class="logo-description-text" style="color: white;">GABINETE DIGITAL</p>
|
|
||||||
<div class="add-line" style="border-bottom: 1px solid white;"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <div class="d-flex flex-1 pr-20 pl-50"
|
|
||||||
*ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access]) && loggeduser.OwnerCalendars.length != 0) || p.userPermission([permissionList.Gabinete.access])"> -->
|
|
||||||
|
|
||||||
<div class="d-flex flex-1 pr-20 pl-50"
|
|
||||||
*ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access])) || p.userPermission([permissionList.Gabinete.access])">
|
|
||||||
|
|
||||||
<div
|
|
||||||
*ngIf="p.userPermission([permissionList.Agenda.access]) || p.userPermission([permissionList.Gabinete.access])"
|
|
||||||
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/events')"
|
|
||||||
[class.active]="ActiveTabService.pages.home">
|
|
||||||
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
|
|
||||||
class="font-40-rem" src='assets/images/icons-nav-home-active-black.svg'></ion-icon>
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
|
|
||||||
src='assets/images/theme/gov/icons-nav-home-active-black.svg'></ion-icon>
|
|
||||||
|
|
||||||
<span>Início</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="p.userPermission([permissionList.Agenda.access])"
|
|
||||||
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/agenda')"
|
|
||||||
[class.active]="ActiveTabService.pages.agenda">
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
|
|
||||||
class="font-40-rem" src='assets/images/icons-nav-agenda-inactive.svg'></ion-icon>
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
|
|
||||||
src='assets/images/theme/gov/icons-nav-agenda-inactive.svg'></ion-icon>
|
|
||||||
|
|
||||||
<span>Agenda</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="p.userPermission([permissionList.Gabinete.access])"
|
|
||||||
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/gabinete-digital')"
|
|
||||||
[class.active]="ActiveTabService.pages.gabinete">
|
|
||||||
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
|
|
||||||
class="font-40-rem" src='assets/images/icons-nav-home-dk.svg'></ion-icon>
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
|
|
||||||
src='assets/images/theme/gov/icons-nav-home-dk.svg'></ion-icon>
|
|
||||||
<span>Gabinete</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="p.userPermission([permissionList.Actions.access])"
|
|
||||||
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/publications')"
|
|
||||||
[class.active]="ActiveTabService.pages.publication">
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
|
|
||||||
class="font-40-rem" src='assets/images/icons-nav-a-es-inactive.svg'></ion-icon>
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
|
|
||||||
src='assets/images/theme/gov/icons-nav-a-es-inactive.svg'></ion-icon>
|
|
||||||
<span>Acções</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="p.userPermission([permissionList.Chat.access])"
|
|
||||||
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/chat')"
|
|
||||||
[class.active]="ActiveTabService.pages.chat">
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
|
|
||||||
class="font-40-rem" src='assets/images/icons-nav-grupos-inactive-dk-white.svg'></ion-icon>
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
|
|
||||||
src='assets/images/theme/gov/icons-nav-grupos-inactive-dk-white.svg'></ion-icon>
|
|
||||||
<span>Chat</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="header-btns d-flex">
|
|
||||||
|
|
||||||
<div *ngIf="PublicationHolderService.count != 0" style="color: black" >
|
|
||||||
<span *ngIf="!PublicationHolderService.PublicationFormMV?.[0]?.retry">{{ PublicationHolderService.count }}%</span>
|
|
||||||
<span style="padding-right: 12px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.PublicationFormMV?.[0]?.retryFunction()" ><ion-icon src="assets/images/retry-svgrepo-com.svg" > </ion-icon></span>
|
|
||||||
<span style="padding-right: 7px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.remove(PublicationHolderService.PublicationFormMV?.[0]?.id)">X</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div title="Pesquisa" *ngIf="!hideSearchBtn" class="mr-20 d-flex align-center cursor-pointer">
|
|
||||||
<div style="padding-top: 5px;" (click)="openSearch();showSearch=true" *ngIf="!showSearch">
|
|
||||||
<ion-icon title="Perfil" *ngIf="ThemeService.currentTheme == 'doneIt' " class="font-45-rem"
|
|
||||||
src="assets/images/theme/doneIt/icons-search.svg"></ion-icon>
|
|
||||||
<ion-icon title="Perfil" *ngIf="ThemeService.currentTheme == 'default' " class="font-45-rem"
|
|
||||||
src='assets/images/icons-search.svg'></ion-icon>
|
|
||||||
<ion-icon title="Perfil" *ngIf="ThemeService.currentTheme == 'gov' " class="font-45-rem"
|
|
||||||
src='assets/images/theme/gov/icons-search.svg'></ion-icon>
|
|
||||||
</div>
|
|
||||||
<button title="Fechar" class="btn-no-color" (click)="closeSearch();showSearch=false;searchSubject=''"
|
|
||||||
*ngIf="showSearch">
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
|
|
||||||
class="font-40-rem" name="restaurant-outline" src="assets/images/icons-search-close.svg"></ion-icon>
|
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem" name="restaurant-outline"
|
|
||||||
src="assets/images/theme/gov/icons-search-close.svg"></ion-icon>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div title="Perfil" class="div-profile d-flex cursor-pointer font-45-rem" (click)="openProfile()">
|
|
||||||
|
|
||||||
<div *ngIf="(profilePictureSubject | async) as calendarData" class="profile-image d-flex">
|
|
||||||
<img *ngIf="calendarData.base64 != null" class="profile-image image-prety" src={{calendarData.base64}}>
|
|
||||||
<ion-icon *ngIf="calendarData.base64 == null"
|
|
||||||
class="icon font-50 image-prety" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="profile-text" *ngIf="(notificationCount$ | async) as notificationCount ">
|
|
||||||
|
|
||||||
<div *ngIf="notificationCount > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
|
|
||||||
{{notificationCount}} </div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div [class.header-bottom-line]="ThemeService.currentTheme == 'gov'" style="height: 5px;"></div>
|
|
||||||
</div>
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Environment } from './../app/models/envarioment'
|
import { Environment } from './../app/models/envarioment'
|
||||||
|
import { DevDev } from './suport/dev';
|
||||||
import { environment as oaprProd } from './suport/oapr'
|
import { environment as oaprProd } from './suport/oapr'
|
||||||
// import { environment as doneITProd } from './suport/doneIt'
|
// import { environment as doneITProd } from './suport/doneIt'
|
||||||
|
|
||||||
|
|
||||||
export const environment: Environment = oaprProd;
|
export const environment: Environment = DevDev;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
export let versionData = {
|
export let versionData = {
|
||||||
"shortSHA": "d1e5387d1",
|
"shortSHA": "0d10ee98f",
|
||||||
"SHA": "d1e5387d1176ad2cf3ddb95aa8b7b319053df214",
|
"SHA": "0d10ee98fa97d9bc5ea61918a942e18669e1691a",
|
||||||
"branch": "developer",
|
"branch": "developer",
|
||||||
"lastCommitAuthor": "'peter.maquiran'",
|
"lastCommitAuthor": "'peter.maquiran'",
|
||||||
"lastCommitTime": "'Fri Sep 5 11:42:36 2025 +0100'",
|
"lastCommitTime": "'Fri Sep 5 12:00:01 2025 +0100'",
|
||||||
"lastCommitMessage": "update image",
|
"lastCommitMessage": "fix profile picture",
|
||||||
"lastCommitNumber": "6145",
|
"lastCommitNumber": "6146",
|
||||||
"changeStatus": "On branch developer\nYour branch is ahead of 'origin/developer' by 2 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/app.module.ts\n\tmodified: src/app/core/user/use-case/user-refresh-token.service.ts\n\tnew file: src/app/ui/shared/components/header/header.page copy.html\n\tmodified: src/app/ui/shared/components/header/header.page.html\n\tmodified: src/app/ui/shared/components/header/header.page.scss",
|
"changeStatus": "On branch developer\nYour branch is ahead of 'origin/developer' by 3 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/core/chat/mapper/messageMapper.ts\n\tmodified: src/app/core/chat/repository/message/message-remote-repository.ts\n\tmodified: src/app/core/chat/repository/message/message-socket-repository.ts\n\tnew file: src/app/core/chat/usecase/message/message-attachment-upload-use-case.service.ts\n\tdeleted: src/app/core/chat/usecase/message/message-create-use-case.service copy.ts\n\tmodified: src/app/core/chat/usecase/message/message-create-use-case.service.ts\n\tmodified: src/app/core/chat/usecase/message/messages-send-offline-use-case.service.ts\n\tmodified: src/app/core/chat/usecase/socket/socket-message-create-use-case.service.ts\n\tmodified: src/app/core/chat/usecase/socket/socket-message-delete-use-case.service.ts\n\tmodified: src/app/core/chat/usecase/socket/socket-message-update-use-case.service.ts\n\tmodified: src/app/core/user/repository/user-remote-repository.ts\n\tmodified: src/app/core/user/use-case/user-get-by-id.service.ts\n\tnew file: src/app/core/user/use-case/user-photo-upload.service.ts\n\tmodified: src/app/infra/database/dexie/instance/chat/schema/attachment.ts\n\tmodified: src/app/infra/file-picker/web/file-picker-web.service.ts\n\tmodified: src/app/modals/profile/edit-profile/edit-profile.page.ts\n\tmodified: src/app/module/chat/data/repository/attachment/attachment-remote-repository.service.ts\n\tmodified: src/app/module/chat/data/repository/message/message-live-signalr-data-source.service.ts\n\tmodified: src/app/module/chat/data/repository/message/message-remote-data-source.service.ts\n\tmodified: src/app/module/user/data/datasource/user-remote-repository.service.ts\n\tmodified: src/app/module/user/data/user-repository.service.ts\n\tmodified: src/app/ui/chat/component/edit-group/edit-group.page.ts\n\tmodified: src/app/ui/chat/component/messages/messages.page.ts\n\tmodified: src/app/ui/chat/modal/edit-group/edit-group.page.ts\n\tmodified: src/app/ui/chat/modal/messages/messages.page.ts\n\tmodified: src/app/ui/chat/store/roomStore.ts\n\tdeleted: src/app/ui/shared/components/header/header.page copy.html\n\tmodified: src/environments/environment.prod.ts\n\tmodified: version/git-version.ts\n\tmodified: web.config",
|
||||||
"changeAuthor": "peter.maquiran"
|
"changeAuthor": "peter.maquiran"
|
||||||
}
|
}
|
||||||
+9
-24
@@ -1,17 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<system.webServer>
|
<system.webServer>
|
||||||
<modules>
|
|
||||||
|
|
||||||
<remove name="WebDAVModule"/>
|
<!-- Add MIME type for APK -->
|
||||||
|
<staticContent>
|
||||||
|
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
|
||||||
|
</staticContent>
|
||||||
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<handlers>
|
|
||||||
|
|
||||||
<remove name="WebDAV"/>
|
|
||||||
|
|
||||||
</handlers>
|
|
||||||
<rewrite>
|
<rewrite>
|
||||||
<rules>
|
<rules>
|
||||||
<rule name="AngularRewrite" stopProcessing="true">
|
<rule name="AngularRewrite" stopProcessing="true">
|
||||||
@@ -24,33 +19,23 @@
|
|||||||
</rule>
|
</rule>
|
||||||
</rules>
|
</rules>
|
||||||
</rewrite>
|
</rewrite>
|
||||||
|
|
||||||
<httpProtocol>
|
<httpProtocol>
|
||||||
<customHeaders>
|
<customHeaders>
|
||||||
<!-- Iframe on the same host only -->
|
<!-- Iframe on the same host only -->
|
||||||
<add name="Content-Security-Policy" value="frame-ancestors https://gdqas.oapr.gov.ao/" />
|
<add name="Content-Security-Policy" value="frame-ancestors https://gdviewer-dev.dyndns.info/" />
|
||||||
<!-- HTTPS on -->
|
<!-- HTTPS on -->
|
||||||
<add name="Strict-Transport-Security" value="max-age=31536000" />
|
<add name="Strict-Transport-Security" value="max-age=31536000" />
|
||||||
<add name="Referrer-Policy" value="no-referrer" />
|
<add name="Referrer-Policy" value="no-referrer" />
|
||||||
<add name="X-Content-Type-Options" value="nosniff" />
|
<add name="X-Content-Type-Options" value="nosniff" />
|
||||||
<!-- <add e="Expect-CT" value="enforce, max-age=86400" /> -->
|
<!-- Permissions -->
|
||||||
<!-- Permision -->
|
|
||||||
<add name="Permissions-Policy" value="camera=(), microphone=*" />
|
<add name="Permissions-Policy" value="camera=(), microphone=*" />
|
||||||
<!-- same origin only -->
|
<!-- CORS and security -->
|
||||||
<add name="Cross-Origin-Resource-Policy" value="cross-origin" />
|
<add name="Cross-Origin-Resource-Policy" value="cross-origin" />
|
||||||
<!-- same origin only -->
|
|
||||||
<add name="Cross-Origin-Opener-Policy" value="require-corp" />
|
<add name="Cross-Origin-Opener-Policy" value="require-corp" />
|
||||||
|
<add name="Access-Control-Allow-Origin" value="*" />
|
||||||
</customHeaders>
|
</customHeaders>
|
||||||
</httpProtocol>
|
</httpProtocol>
|
||||||
|
|
||||||
|
|
||||||
<!-- <directoryBrowse enabled="false" />
|
|
||||||
<httpErrors>
|
|
||||||
<remove statusCode="404" subStatusCode="-1" />
|
|
||||||
<remove statusCode="403" subStatusCode="-1" />
|
|
||||||
<error statusCode="403" prefixLanguageFilePath="" path="/home/events" responseMode="ExecuteURL" />
|
|
||||||
<error statusCode="404" prefixLanguageFilePath="" path="/index.html" responseMode="ExecuteURL" />
|
|
||||||
</httpErrors> -->
|
|
||||||
|
|
||||||
|
|
||||||
</system.webServer>
|
</system.webServer>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
Reference in New Issue
Block a user