diff --git a/projects/ucap-webmessenger-api-common/src/lib/apis/file-talk-share.ts b/projects/ucap-webmessenger-api-common/src/lib/apis/file-talk-share.ts index 6213f701..82ef3b8f 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/apis/file-talk-share.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/apis/file-talk-share.ts @@ -5,7 +5,6 @@ import { APIEncoder, APIDecoder, ParameterUtil, - JsonAnalization, StatusCode } from '@ucap-webmessenger/api'; @@ -51,20 +50,19 @@ export const decodeFileTalkShare: APIDecoder = ( res: any ) => { try { - const json = JsonAnalization.receiveAnalization(res); return { - statusCode: json.StatusCode, - roomSeq: json.RoomID, - fileName: json.FileName, - fileExt: json.FileExt, - fileType: json.FileType, - thumbnailUrl: json.ThumbURL, - attachmentSeq: json.AttSEQ, - attachmentSize: json.AttSize, - attachmentRegDate: json.AttRegDate, - companyCode: json.CompanyCode, - synapKey: json.SynapKey, - returnJson: res + statusCode: res.StatusCode, + roomSeq: res.RoomID, + fileName: res.FileName, + fileExt: res.FileExt, + fileType: res.FileType, + thumbnailUrl: res.ThumbURL, + attachmentSeq: res.AttSEQ, + attachmentSize: res.AttSize, + attachmentRegDate: res.AttRegDate, + companyCode: res.CompanyCode, + synapKey: res.SynapKey, + returnJson: JSON.stringify(res) } as FileTalkShareResponse; } catch (e) { return { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts index b70ce3ce..43b44ca7 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts @@ -46,7 +46,8 @@ import { import { RoomInfo, UserInfoShort, - UserInfo as RoomUserInfo + UserInfo as RoomUserInfo, + RoomType } from '@ucap-webmessenger/protocol-room'; import { ConfirmDialogComponent, @@ -547,6 +548,10 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { } } onToggleRoom(roomInfo: RoomInfo) { + if (!this.getCheckableRoom(roomInfo)) { + return; + } + if (!!this.selectedRoom) { if (this.selectedRoom.roomSeq === roomInfo.roomSeq) { this.selectedRoom = null; @@ -591,6 +596,16 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { // .length > 0 // ); // } + if ( + roomInfo.roomType === RoomType.Bot || + roomInfo.roomType === RoomType.Allim || + roomInfo.roomType === RoomType.Link || + roomInfo.roomType === RoomType.Allim_Elephant || + roomInfo.roomType === RoomType.Allim_TMS + ) { + return false; + } + return true; } getCheckedRoom(roomInfo: RoomInfo) { @@ -611,6 +626,12 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { getBtnValid() { if (this.data.type === UserSelectDialogType.NewGroup) { return this.inputForm.invalid; + } else if (this.data.type === UserSelectDialogType.MessageForward) { + if (this.selectedUserList.length === 0 && !this.selectedRoom) { + return true; + } + + return false; } else { return false; } diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts index acb4be9c..80831cb7 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts @@ -1,6 +1,7 @@ import { CommonApiService, - MassTalkSaveRequest + MassTalkSaveRequest, + FileTalkShareRequest } from '@ucap-webmessenger/api-common'; import { KEY_ENVIRONMENTS_INFO } from './../../../types/environment.type'; import { Injectable } from '@angular/core'; @@ -19,7 +20,8 @@ import { catchError, exhaustMap, withLatestFrom, - concatMap + concatMap, + take } from 'rxjs/operators'; import moment from 'moment'; import { @@ -43,7 +45,8 @@ import { FileEventJson, MassTextEventJson, TranslationEventJson, - MassTranslationEventJson + MassTranslationEventJson, + decodeFileEventJson } from '@ucap-webmessenger/protocol-event'; import * as ChatStore from '@app/store/messenger/chat'; @@ -83,7 +86,8 @@ import { roomOpenAfterForward, infoForSearch, infoForSearchEnd, - infoAll + infoAll, + forwardFailure } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { @@ -663,8 +667,52 @@ export class Effects { ofType(forward), tap(action => { if (!!action.trgtRoomSeq) { - // 대화전달 후 방오픈. - this.store.dispatch(roomOpenAfterForward(action)); + // 대화전달 후 방오픈. Exist roomSeq. + if (action.req.eventType === EventType.File) { + const loginResInfo: LoginResponse = this.sessionStorageService.get< + LoginResponse + >(KEY_LOGIN_RES_INFO); + + const environmentsInfo = this.sessionStorageService.get< + EnvironmentsInfo + >(KEY_ENVIRONMENTS_INFO); + + const fileEventJson: FileEventJson = decodeFileEventJson( + action.req.sentMessage + ); + const req: FileTalkShareRequest = { + userSeq: loginResInfo.userSeq, + deviceType: environmentsInfo.deviceType, + token: loginResInfo.tokenString, + attachmentsSeq: fileEventJson.attachmentSeq.toString(), + roomSeq: action.trgtRoomSeq, + synapKey: '' + }; + this.commonApiService + .fileTalkShare(req) + .pipe( + take(1), + map(res => { + if (res.statusCode === StatusCode.Success) { + action = { + ...action, + req: { + ...action.req, + sentMessage: res.returnJson + } + }; + + this.store.dispatch(roomOpenAfterForward(action)); + } else { + this.store.dispatch(forwardFailure({ error: res })); + } + }), + catchError(error => of(forwardFailure({ error }))) + ) + .subscribe(); + } else { + this.store.dispatch(roomOpenAfterForward(action)); + } } else if (!!action.trgtUserSeqs && action.trgtUserSeqs.length > 0) { // 방오픈 후 대화전달. this.store.dispatch(forwardAfterRoomOpen(action)); @@ -689,16 +737,70 @@ export class Effects { return openSuccess({ res }); }), map(res => { - this.store.dispatch( - send({ - senderSeq: action.senderSeq, - req: { - roomSeq: res.res.roomSeq, - eventType: action.req.eventType, - sentMessage: action.req.sentMessage - } - }) - ); + if (action.req.eventType === EventType.File) { + const loginResInfo: LoginResponse = this.sessionStorageService.get< + LoginResponse + >(KEY_LOGIN_RES_INFO); + + const environmentsInfo = this.sessionStorageService.get< + EnvironmentsInfo + >(KEY_ENVIRONMENTS_INFO); + + const fileEventJson: FileEventJson = decodeFileEventJson( + action.req.sentMessage + ); + const req: FileTalkShareRequest = { + userSeq: loginResInfo.userSeq, + deviceType: environmentsInfo.deviceType, + token: loginResInfo.tokenString, + attachmentsSeq: fileEventJson.attachmentSeq.toString(), + roomSeq: action.trgtRoomSeq, + synapKey: '' + }; + this.commonApiService + .fileTalkShare(req) + .pipe( + take(1), + map(resFileShare => { + if (resFileShare.statusCode === StatusCode.Success) { + action = { + ...action, + req: { + ...action.req, + sentMessage: resFileShare.returnJson + } + }; + + this.store.dispatch( + send({ + senderSeq: action.senderSeq, + req: { + roomSeq: res.res.roomSeq, + eventType: action.req.eventType, + sentMessage: action.req.sentMessage + } + }) + ); + } else { + this.store.dispatch(forwardFailure({ error: res })); + } + }), + catchError(error => of(forwardFailure({ error }))) + ) + .subscribe(); + } else { + this.store.dispatch( + send({ + senderSeq: action.senderSeq, + req: { + roomSeq: res.res.roomSeq, + eventType: action.req.eventType, + sentMessage: action.req.sentMessage + } + }) + ); + } + return res; }), catchError(error => of(openFailure({ error })))