feat : 자료실 글에 원본 설명글(description) 저장, 제목 미입력 시 설명 첫 줄을 제목으로
SpecialSource Backend CI/CD / build-and-deploy (push) Successful in 55s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
headporterandClaude Opus 5.5 committed 2026-11-30 11:04:14 +09:00
1 parent 4d8d1cfff6
commit 97ab728701
2 files changed
+17 -4

No files matched your search

@@ -75,11 +75,12 @@ public class MediaPostController {
public record UpdateRequest(String title, String category) {} public record UpdateRequest(String title, String category) {}
// result: VIDEO / IMAGE / FAIL = 끝남, PROGRESS = 받는 중 (progress %, speed) // 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 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, Integer progress, String speed, String author, LocalDateTime createdAt,
List<FileItem> files) {} List<FileItem> files) {}
@@ -266,12 +267,20 @@ public class MediaPostController {
List<Path> files = listFiles(post.getFolder()); List<Path> files = listFiles(post.getFolder());
boolean ok = !"FAIL".equals(request.result()) && !files.isEmpty(); boolean ok = !"FAIL".equals(request.result()) && !files.isEmpty();
post.setStatus(ok ? MediaPost.Status.DONE : MediaPost.Status.FAILED); 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에 '_'가 있으면 일부가 제목에 남음. 거슬리면 봇이 콜백에 제목을 실어 보내게 // ponytail: 영상 id에 '_'가 있으면 일부가 제목에 남음. 거슬리면 봇이 콜백에 제목을 실어 보내게
if (ok && post.getTitle().equals(post.getSourceUrl())) { if (ok && post.getTitle().equals(post.getSourceUrl())) {
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("\\.[^.]+$", ""); String name = files.get(0).getFileName().toString().replaceFirst("\\.[^.]+$", "");
post.setTitle(name.replaceFirst("_[^_]+_(Video|Image)\\d+$", "")); post.setTitle(name.replaceFirst("_[^_]+_(Video|Image)\\d+$", ""));
} }
}
repository.save(post); repository.save(post);
return ResponseEntity.noContent().build(); 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)); 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); post.getStatus(), post.getProgress(), post.getSpeed(), post.getAuthor(), post.getCreatedAt(), items);
} }
@@ -44,6 +44,10 @@ public class MediaPost {
@Column(name = "created_at", nullable = false) @Column(name = "created_at", nullable = false)
private LocalDateTime createdAt; private LocalDateTime createdAt;
@Setter
@Column(columnDefinition = "TEXT")
private String description; // 원본 게시물 설명글 (인스타 본문). 봇이 다 받으면 채움, 없으면 null
@Setter @Setter
@Column(length = 50) @Column(length = 50)
private String category; // 자료실 분류. null = 미분류. 목록은 글들에서 자동으로 모음 private String category; // 자료실 분류. null = 미분류. 목록은 글들에서 자동으로 모음