@@ -23,6 +23,7 @@ import { InitLandingResponseDto } from './dto/InitLandingResponse.dto';
23
23
import { MemoColorUpdateRequestDto } from './dto/MemoColorUpdateRequest.dto' ;
24
24
import { MemberUpdateRequestDto } from './dto/MemberUpdateRequest.dto' ;
25
25
import { MemberStatus } from './enum/MemberStatus.enum' ;
26
+ import { LinkCreateRequestDto } from './dto/LinkCreateRequest.dto' ;
26
27
27
28
export interface ClientSocket extends Socket {
28
29
projectId ?: number ;
@@ -252,6 +253,36 @@ export class ProjectWebsocketGateway
252
253
this . sendMemberStatusUpdate ( client ) ;
253
254
}
254
255
256
+ @SubscribeMessage ( 'link' )
257
+ async handleLinkEvent (
258
+ @ConnectedSocket ( ) client : ClientSocket ,
259
+ @MessageBody ( ) data : LinkCreateRequestDto ,
260
+ ) {
261
+ if ( data . action === 'create' ) {
262
+ const errors = await validate ( plainToClass ( LinkCreateRequestDto , data ) ) ;
263
+ if ( errors . length > 0 ) {
264
+ const errorList = this . getRecursiveErrorMsgList ( errors ) ;
265
+ client . emit ( 'error' , { errorList } ) ;
266
+ return ;
267
+ }
268
+ const { content } = data as LinkCreateRequestDto ;
269
+ const createLink = await this . projectService . createLink (
270
+ client . project ,
271
+ content . url ,
272
+ content . description ,
273
+ ) ;
274
+ client . nsp . to ( 'landing' ) . emit ( 'landing' , {
275
+ domain : 'link' ,
276
+ action : 'create' ,
277
+ content : {
278
+ id : createLink . id ,
279
+ url : createLink . url ,
280
+ description : createLink . description ,
281
+ } ,
282
+ } ) ;
283
+ }
284
+ }
285
+
255
286
notifyJoinToConnectedMembers ( projectId : number , member : Member ) {
256
287
const projectNamespace = this . namespaceMap . get ( projectId ) ;
257
288
if ( ! projectNamespace ) return ;
0 commit comments