mirror of
https://github.com/headporter81/specialsource-homepage-backend.git
synced 2026-12-06 07:41:09 +09:00
feat : 자료실 글에 원본 설명글(description) 저장, 제목 미입력 시 설명 첫 줄을 제목으로
SpecialSource Backend CI/CD / build-and-deploy (push) Successful in 55s
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:
1 parent
4d8d1cfff6
commit
97ab728701
2 files changed
+19
-6
No files matched your search
@@ -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<FileItem> files) {}
|
||||
|
||||
@@ -266,11 +267,19 @@ public class MediaPostController {
|
||||
List<Path> 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user