From 97ab72870189c6afd07320477268ba9f2e0468aa Mon Sep 17 00:00:00 2001 From: "sungjin.choi" Date: Mon, 30 Nov 2026 11:04:14 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=9E=90=EB=A3=8C=EC=8B=A4=20?= =?UTF-8?q?=EA=B8=80=EC=97=90=20=EC=9B=90=EB=B3=B8=20=EC=84=A4=EB=AA=85?= =?UTF-8?q?=EA=B8=80(description)=20=EC=A0=80=EC=9E=A5,=20=EC=A0=9C?= =?UTF-8?q?=EB=AA=A9=20=EB=AF=B8=EC=9E=85=EB=A0=A5=20=EC=8B=9C=20=EC=84=A4?= =?UTF-8?q?=EB=AA=85=20=EC=B2=AB=20=EC=A4=84=EC=9D=84=20=EC=A0=9C=EB=AA=A9?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../controller/MediaPostController.java | 21 +++++++++++++------ .../specialsource/entity/MediaPost.java | 4 ++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/company/specialsource/controller/MediaPostController.java b/src/main/java/company/specialsource/controller/MediaPostController.java index b06a4e4..f916511 100644 --- a/src/main/java/company/specialsource/controller/MediaPostController.java +++ b/src/main/java/company/specialsource/controller/MediaPostController.java @@ -75,11 +75,12 @@ public class MediaPostController { public record UpdateRequest(String title, String category) {} // result: VIDEO / IMAGE / FAIL = 끝남, PROGRESS = 받는 중 (progress %, speed) - public record CallbackRequest(String folder, String result, Integer progress, String speed) {} + // description: 끝날 때 원본 게시물 설명글 (인스타 본문, 없으면 null) + public record CallbackRequest(String folder, String result, Integer progress, String speed, String description) {} public record FileItem(String name, String type, long size, String url) {} // size: 바이트 - public record MediaPostResponse(Long id, String title, String sourceUrl, String category, MediaPost.Status status, + public record MediaPostResponse(Long id, String title, String description, String sourceUrl, String category, MediaPost.Status status, Integer progress, String speed, String author, LocalDateTime createdAt, List files) {} @@ -266,11 +267,19 @@ public class MediaPostController { List files = listFiles(post.getFolder()); boolean ok = !"FAIL".equals(request.result()) && !files.isEmpty(); post.setStatus(ok ? MediaPost.Status.DONE : MediaPost.Status.FAILED); - // 제목을 안 적었으면(= 링크) 첫 파일 이름으로. 봇 파일명 "제목_영상id_Video1.mp4" 에서 뒤쪽 제거 + String description = request.description() == null || request.description().isBlank() ? null : request.description().trim(); + if (ok && description != null) post.setDescription(description); + // 제목을 안 적었으면(= 링크): 설명글 첫 줄(최대 100자), 없으면 첫 파일 이름으로 + // 봇 파일명 "제목_영상id_Video1.mp4" 에서 뒤쪽 제거 // ponytail: 영상 id에 '_'가 있으면 일부가 제목에 남음. 거슬리면 봇이 콜백에 제목을 실어 보내게 if (ok && post.getTitle().equals(post.getSourceUrl())) { - String name = files.get(0).getFileName().toString().replaceFirst("\\.[^.]+$", ""); - post.setTitle(name.replaceFirst("_[^_]+_(Video|Image)\\d+$", "")); + if (description != null) { + String first = description.lines().map(String::strip).filter(l -> !l.isEmpty()).findFirst().orElse(description); + post.setTitle(first.length() > 100 ? first.substring(0, 100) + "…" : first); + } else { + String name = files.get(0).getFileName().toString().replaceFirst("\\.[^.]+$", ""); + post.setTitle(name.replaceFirst("_[^_]+_(Video|Image)\\d+$", "")); + } } repository.save(post); return ResponseEntity.noContent().build(); @@ -294,7 +303,7 @@ public class MediaPostController { items.add(new FileItem(name, type, size, "/api/media-posts/files/" + post.getFolder() + "/" + i + "?t=" + token)); } } - return new MediaPostResponse(post.getId(), post.getTitle(), post.getSourceUrl(), post.getCategory(), + return new MediaPostResponse(post.getId(), post.getTitle(), post.getDescription(), post.getSourceUrl(), post.getCategory(), post.getStatus(), post.getProgress(), post.getSpeed(), post.getAuthor(), post.getCreatedAt(), items); } diff --git a/src/main/java/company/specialsource/entity/MediaPost.java b/src/main/java/company/specialsource/entity/MediaPost.java index 8ea6d31..f9c2ca6 100644 --- a/src/main/java/company/specialsource/entity/MediaPost.java +++ b/src/main/java/company/specialsource/entity/MediaPost.java @@ -44,6 +44,10 @@ public class MediaPost { @Column(name = "created_at", nullable = false) private LocalDateTime createdAt; + @Setter + @Column(columnDefinition = "TEXT") + private String description; // 원본 게시물 설명글 (인스타 본문). 봇이 다 받으면 채움, 없으면 null + @Setter @Column(length = 50) private String category; // 자료실 분류. null = 미분류. 목록은 글들에서 자동으로 모음