diff --git a/share/package.json b/share/package.json index afc31671..d4c36584 100644 --- a/share/package.json +++ b/share/package.json @@ -1,6 +1,6 @@ { "name": "@grimity/dto", - "version": "1.0.29", + "version": "1.0.30", "types": "dist/share/index.d.ts", "exports": { ".": { diff --git a/src/module/album/dto/album.response.ts b/src/module/album/dto/album.base.response.ts similarity index 100% rename from src/module/album/dto/album.response.ts rename to src/module/album/dto/album.base.response.ts diff --git a/src/module/album/dto/index.ts b/src/module/album/dto/index.ts index 80f1d387..6ae0da21 100644 --- a/src/module/album/dto/index.ts +++ b/src/module/album/dto/index.ts @@ -1,2 +1,2 @@ export * from './album.request'; -export * from './album.response'; +export * from './album.base.response'; diff --git a/src/module/chat/dto/chat-message.base.response.ts b/src/module/chat/dto/chat-message.base.response.ts new file mode 100644 index 00000000..5ed9007d --- /dev/null +++ b/src/module/chat/dto/chat-message.base.response.ts @@ -0,0 +1,19 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class ChatMessageBaseResponse { + @ApiProperty() + id: string; + + @ApiProperty({ type: 'string', nullable: true }) + content: string | null; + + @ApiProperty({ + type: 'string', + nullable: true, + example: 'https://image.grimity.com/chat/123.webp', + }) + image: string | null; + + @ApiProperty() + createdAt: Date; +} diff --git a/src/module/chat/dto/chat-message.response.ts b/src/module/chat/dto/chat-message.response.ts index 9b186391..2373a300 100644 --- a/src/module/chat/dto/chat-message.response.ts +++ b/src/module/chat/dto/chat-message.response.ts @@ -1,24 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { CursorResponse } from '../../../shared/response'; -import { UserBaseResponse } from '../../../module/user/dto'; - -export class ChatMessageBaseResponse { - @ApiProperty() - id: string; - - @ApiProperty({ type: 'string', nullable: true }) - content: string | null; - - @ApiProperty({ - type: 'string', - nullable: true, - example: 'https://image.grimity.com/chat/123.webp', - }) - image: string | null; - - @ApiProperty() - createdAt: Date; -} +import { UserBaseResponse } from '../../user/dto'; +import { ChatMessageBaseResponse } from './chat-message.base.response'; export class ReplyToResponse extends ChatMessageBaseResponse {} diff --git a/src/module/chat/dto/chat.response.ts b/src/module/chat/dto/chat.response.ts index 6239fd09..47af0bfe 100644 --- a/src/module/chat/dto/chat.response.ts +++ b/src/module/chat/dto/chat.response.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { CursorResponse } from '../../../shared/response'; -import { UserBaseResponse } from '../../../module/user/dto'; -import { ChatMessageBaseResponse } from './chat-message.response'; +import { UserBaseResponse } from '../../user/dto'; +import { ChatMessageBaseResponse } from './chat-message.base.response'; export class LastChatMessageResponse extends ChatMessageBaseResponse { @ApiProperty({ diff --git a/src/module/chat/dto/index.ts b/src/module/chat/dto/index.ts index 26916691..637ca25a 100644 --- a/src/module/chat/dto/index.ts +++ b/src/module/chat/dto/index.ts @@ -1,5 +1,6 @@ export * from './chat.request'; export * from './chat.response'; +export * from './chat-message.base.response'; export * from './chat-message.request'; export * from './chat-message.response'; diff --git a/src/module/feed-comment/dto/feed-comment.base.response.ts b/src/module/feed-comment/dto/feed-comment.base.response.ts new file mode 100644 index 00000000..e33dc56d --- /dev/null +++ b/src/module/feed-comment/dto/feed-comment.base.response.ts @@ -0,0 +1,15 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class FeedCommentBaseResponse { + @ApiProperty() + id: string; + + @ApiProperty() + content: string; + + @ApiProperty() + createdAt: Date; + + @ApiProperty() + likeCount: number; +} diff --git a/src/module/feed-comment/dto/feed-comment.response.ts b/src/module/feed-comment/dto/feed-comment.response.ts index 13e27832..dfd16028 100644 --- a/src/module/feed-comment/dto/feed-comment.response.ts +++ b/src/module/feed-comment/dto/feed-comment.response.ts @@ -1,24 +1,13 @@ import { ApiProperty } from '@nestjs/swagger'; -import { UserBaseResponse } from '../../user/dto/user.dto.response'; - -export class FeedCommentBaseResponse { - @ApiProperty() - id: string; - - @ApiProperty() - content: string; - - @ApiProperty() - createdAt: Date; - - @ApiProperty() - likeCount: number; +import { UserBaseResponse } from '../../user/dto/user.base.response'; +import { FeedCommentBaseResponse } from './feed-comment.base.response'; +export class FeedCommentWithWriterResponse extends FeedCommentBaseResponse { @ApiProperty({ type: UserBaseResponse }) writer: UserBaseResponse; } -export class ChildFeedCommentResponse extends FeedCommentBaseResponse { +export class ChildFeedCommentResponse extends FeedCommentWithWriterResponse { @ApiProperty({ type: UserBaseResponse, nullable: true }) mentionedUser: UserBaseResponse | null; @@ -26,7 +15,7 @@ export class ChildFeedCommentResponse extends FeedCommentBaseResponse { isLike: boolean; } -export class ParentFeedCommentResponse extends FeedCommentBaseResponse { +export class ParentFeedCommentResponse extends FeedCommentWithWriterResponse { @ApiProperty({ type: ChildFeedCommentResponse, isArray: true }) childComments: ChildFeedCommentResponse[]; diff --git a/src/module/feed-comment/dto/index.ts b/src/module/feed-comment/dto/index.ts index 28e028da..a9d31e17 100644 --- a/src/module/feed-comment/dto/index.ts +++ b/src/module/feed-comment/dto/index.ts @@ -1,2 +1,4 @@ +export * from './feed-comment.base.response'; + export * from './feed-comment.request'; export * from './feed-comment.response'; diff --git a/src/module/feed/dto/feed.base.response.ts b/src/module/feed/dto/feed.base.response.ts new file mode 100644 index 00000000..0d0665ba --- /dev/null +++ b/src/module/feed/dto/feed.base.response.ts @@ -0,0 +1,32 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class FeedBaseResponse { + @ApiProperty() + id: string; + + @ApiProperty() + title: string; + + @ApiProperty({ example: 'feed/UUID.webp' }) + thumbnail: string; + + @ApiProperty() + likeCount: number; + + @ApiProperty() + viewCount: number; +} + +export class FeedResponse extends FeedBaseResponse { + @ApiProperty({ type: 'string', isArray: true, example: ['feed/UUID.webp'] }) + cards: string[]; + + @ApiProperty() + createdAt: Date; + + @ApiProperty() + content: string; + + @ApiProperty() + tags: string[]; +} diff --git a/src/module/feed/dto/feed.response.ts b/src/module/feed/dto/feed.response.ts index acbdc2df..61742ca8 100644 --- a/src/module/feed/dto/feed.response.ts +++ b/src/module/feed/dto/feed.response.ts @@ -2,45 +2,13 @@ import { ApiProperty } from '@nestjs/swagger'; import { UserBaseResponse, UserBaseWithBlockedResponse, -} from '../../user/dto/user.dto.response'; +} from '../../user/dto/user.base.response'; import { CursorAndCountResponse, CursorResponse, } from '../../../shared/response/cursor.response'; -import { AlbumBaseResponse } from '../../album/dto/album.response'; import { FeedCommentBaseResponse } from 'src/module/feed-comment/dto'; - -// 최소단위 -export class FeedBaseResponse { - @ApiProperty() - id: string; - - @ApiProperty() - title: string; - - @ApiProperty({ example: 'feed/UUID.webp' }) - thumbnail: string; - - @ApiProperty() - likeCount: number; - - @ApiProperty() - viewCount: number; -} - -export class FeedResponse extends FeedBaseResponse { - @ApiProperty({ type: 'string', isArray: true, example: ['feed/UUID.webp'] }) - cards: string[]; - - @ApiProperty() - createdAt: Date; - - @ApiProperty() - content: string; - - @ApiProperty() - tags: string[]; -} +import { FeedBaseResponse, FeedResponse } from './feed.base.response'; export class SearchedFeedResponse extends FeedBaseResponse { @ApiProperty({ type: UserBaseResponse }) diff --git a/src/module/feed/dto/index.ts b/src/module/feed/dto/index.ts index 87381914..bd36f788 100644 --- a/src/module/feed/dto/index.ts +++ b/src/module/feed/dto/index.ts @@ -1,2 +1,4 @@ +export * from './feed.base.response'; + export * from './feed.request'; export * from './feed.response'; diff --git a/src/module/post-comment/dto/index.ts b/src/module/post-comment/dto/index.ts index bd46718e..0ea67bdb 100644 --- a/src/module/post-comment/dto/index.ts +++ b/src/module/post-comment/dto/index.ts @@ -1,2 +1,4 @@ +export * from './post-comment.base.response'; + export * from './post-comment.request'; export * from './post-comment.response'; diff --git a/src/module/post-comment/dto/post-comment.base.response.ts b/src/module/post-comment/dto/post-comment.base.response.ts new file mode 100644 index 00000000..f3c78e20 --- /dev/null +++ b/src/module/post-comment/dto/post-comment.base.response.ts @@ -0,0 +1,18 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class PostCommentBaseResponse { + @ApiProperty() + id: string; + + @ApiProperty() + content: string; + + @ApiProperty() + createdAt: Date; + + @ApiProperty() + likeCount: number; + + @ApiProperty() + isLike: boolean; +} diff --git a/src/module/post-comment/dto/post-comment.response.ts b/src/module/post-comment/dto/post-comment.response.ts index bbd890e2..f13d6b36 100644 --- a/src/module/post-comment/dto/post-comment.response.ts +++ b/src/module/post-comment/dto/post-comment.response.ts @@ -1,36 +1,22 @@ import { ApiProperty } from '@nestjs/swagger'; -import { UserBaseResponse } from '../../user/dto/user.dto.response'; - -export class PostCommentBaseResponse { - @ApiProperty() - id: string; - - @ApiProperty() - content: string; - - @ApiProperty() - createdAt: Date; - - @ApiProperty() - likeCount: number; +import { UserBaseResponse } from '../../user/dto/user.base.response'; +import { PostCommentBaseResponse } from './post-comment.base.response'; +export class PostCommentWithWriterResponse extends PostCommentBaseResponse { @ApiProperty({ type: UserBaseResponse, nullable: true, description: 'null이면 익명화', }) writer: UserBaseResponse | null; - - @ApiProperty() - isLike: boolean; } -export class ChildPostCommentResponse extends PostCommentBaseResponse { +export class ChildPostCommentResponse extends PostCommentWithWriterResponse { @ApiProperty({ type: UserBaseResponse, nullable: true }) mentionedUser: UserBaseResponse | null; } -export class ParentPostCommentResponse extends PostCommentBaseResponse { +export class ParentPostCommentResponse extends PostCommentWithWriterResponse { @ApiProperty() isDeleted: boolean; diff --git a/src/module/post/dto/index.ts b/src/module/post/dto/index.ts index 05f69a3f..e0887bbb 100644 --- a/src/module/post/dto/index.ts +++ b/src/module/post/dto/index.ts @@ -1,2 +1,4 @@ +export * from './post.base.response'; + export * from './post.request'; export * from './post.response'; diff --git a/src/module/post/dto/post.base.response.ts b/src/module/post/dto/post.base.response.ts new file mode 100644 index 00000000..67c8a27c --- /dev/null +++ b/src/module/post/dto/post.base.response.ts @@ -0,0 +1,30 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { postTypes } from '../../../common/constants/post.constant'; + +export class PostBaseResponse { + @ApiProperty() + id: string; + + @ApiProperty() + title: string; + + @ApiProperty() + content: string; + + @ApiProperty({ type: 'string', nullable: true, description: 'FULL URL' }) + thumbnail: string | null; + + @ApiProperty() + createdAt: Date; +} + +export class PostResponse extends PostBaseResponse { + @ApiProperty({ enum: postTypes }) + type: (typeof postTypes)[number]; + + @ApiProperty() + viewCount: number; + + @ApiProperty() + commentCount: number; +} diff --git a/src/module/post/dto/post.response.ts b/src/module/post/dto/post.response.ts index 2ab2b0b2..b2813e60 100644 --- a/src/module/post/dto/post.response.ts +++ b/src/module/post/dto/post.response.ts @@ -2,44 +2,19 @@ import { ApiProperty } from '@nestjs/swagger'; import { UserBaseResponse } from '../../user/dto'; import { TotalCountResponse } from '../../../shared/response/total-count.response'; import { postTypes } from '../../../common/constants/post.constant'; +import { PostBaseResponse, PostResponse } from './post.base.response'; -export class PostBaseResponse { - @ApiProperty() - id: string; - - @ApiProperty() - title: string; - - @ApiProperty() - content: string; - - @ApiProperty({ type: 'string', nullable: true, description: 'FULL URL' }) - thumbnail: string | null; - - @ApiProperty() - createdAt: Date; -} - -export class PostResponse extends PostBaseResponse { - @ApiProperty({ enum: postTypes }) - type: (typeof postTypes)[number]; - - @ApiProperty() - viewCount: number; - - @ApiProperty() - commentCount: number; - +export class PostWithAuthorResponse extends PostResponse { @ApiProperty({ type: UserBaseResponse }) author: UserBaseResponse; } export class PostsResponse extends TotalCountResponse { - @ApiProperty({ type: PostResponse, isArray: true }) - posts: PostResponse[]; + @ApiProperty({ type: PostWithAuthorResponse, isArray: true }) + posts: PostWithAuthorResponse[]; } -export class PostDetailResponse extends PostResponse { +export class PostDetailResponse extends PostWithAuthorResponse { @ApiProperty() likeCount: number; @@ -51,8 +26,8 @@ export class PostDetailResponse extends PostResponse { } export class MySavePostsResponse extends TotalCountResponse { - @ApiProperty({ type: PostResponse, isArray: true }) - posts: PostResponse[]; + @ApiProperty({ type: PostWithAuthorResponse, isArray: true }) + posts: PostWithAuthorResponse[]; } export class MyPostResponse extends PostBaseResponse { diff --git a/src/module/post/post.controller.ts b/src/module/post/post.controller.ts index 6da5fff5..c7d82a49 100644 --- a/src/module/post/post.controller.ts +++ b/src/module/post/post.controller.ts @@ -28,11 +28,11 @@ import { } from './dto/post.request'; import { IdResponse } from 'src/shared/response/id.response'; import { - PostBaseResponse, - PostResponse, PostsResponse, PostDetailResponse, + PostWithAuthorResponse, } from './dto/post.response'; +import { PostBaseResponse } from './dto'; @ApiTags('/posts') @ApiResponse({ status: 401, description: 'Unauthorized' }) @@ -67,9 +67,9 @@ export class PostController { } @ApiOperation({ summary: '공지사항 조회' }) - @ApiResponse({ status: 200, type: [PostResponse] }) + @ApiResponse({ status: 200, type: [PostWithAuthorResponse] }) @Get('notices') - async getNotices(): Promise { + async getNotices(): Promise { return await this.postService.getNotices(); } diff --git a/src/module/push/push.service.ts b/src/module/push/push.service.ts index 58358878..3e56dfcb 100644 --- a/src/module/push/push.service.ts +++ b/src/module/push/push.service.ts @@ -79,12 +79,13 @@ export class PushService implements OnModuleInit { fcmOptions: { ...(data.imageUrl && { imageUrl: data.imageUrl }), // 여기에 이미지 URL }, - ...(data.silent && { - headers: { + headers: { + ...(data.silent && { 'apns-priority': '5', // silent 푸시를 위한 우선순위 설정 'apns-push-type': 'background', - }, - }), + }), + ...(data.key && { 'apns-collapse-id': data.key }), // 같은 key면 기존 알림 덮어씀 + }, }; try { diff --git a/src/module/user/dto/index.ts b/src/module/user/dto/index.ts index 4c4d9359..81cd4d7f 100644 --- a/src/module/user/dto/index.ts +++ b/src/module/user/dto/index.ts @@ -1,4 +1,4 @@ -export * from './user.dto.response'; +export * from './user.base.response'; export * from './user.request'; export * from './user.response'; diff --git a/src/module/user/dto/user.dto.response.ts b/src/module/user/dto/user.base.response.ts similarity index 100% rename from src/module/user/dto/user.dto.response.ts rename to src/module/user/dto/user.base.response.ts diff --git a/src/module/user/dto/user.response.ts b/src/module/user/dto/user.response.ts index e4762a0f..4cf13787 100644 --- a/src/module/user/dto/user.response.ts +++ b/src/module/user/dto/user.response.ts @@ -5,11 +5,11 @@ import { CursorAndCountResponse, } from '../../../shared/response/cursor.response'; import { ConflictResponse } from '../../../shared/response/conflict.response'; -import { AlbumBaseResponse } from '../../album/dto/album.response'; +import { AlbumBaseResponse } from '../../album/dto/album.base.response'; import { UserBaseResponse, UserBaseWithBlockedResponse, -} from './user.dto.response'; +} from './user.base.response'; export class LinkResponse { @ApiProperty({ example: '인스타그램' }) diff --git a/src/module/user/me.controller.ts b/src/module/user/me.controller.ts index e09afd68..96447f8f 100644 --- a/src/module/user/me.controller.ts +++ b/src/module/user/me.controller.ts @@ -29,7 +29,7 @@ import { GetFollowingRequest, RegisterPushTokenRequest, } from './dto/user.request'; -import { AlbumBaseResponse } from '../album/dto/album.response'; +import { AlbumBaseResponse } from '../album/dto/album.base.response'; import { MyProfileResponse, UpdateProfileConflictResponse,