target fix

This commit is contained in:
arys
2026-04-06 16:56:55 +05:00
parent db565e6f95
commit f9b6f18c03
3 changed files with 43 additions and 4 deletions
@@ -50,6 +50,9 @@ public class PostingTask {
@Field("image_filename")
private String imageFilename;
@Field("video_filename")
private String videoFilename;
public PostingTask() {
this.createdAt = LocalDateTime.now();
this.status = "pending";
@@ -170,5 +173,13 @@ public class PostingTask {
public void setImageFilename(String imageFilename) {
this.imageFilename = imageFilename;
}
public String getVideoFilename() {
return videoFilename;
}
public void setVideoFilename(String videoFilename) {
this.videoFilename = videoFilename;
}
}
@@ -1211,8 +1211,19 @@ public class MarketingStrategyV3Service {
MarketingStrategy.PostCalendarItem fbPost = fbPostOpt.get();
// Пробуем загрузить видео — приоритет над фото
byte[] videoData = null;
if (fbPost.getVideoFilename() != null && !fbPost.getVideoFilename().isEmpty()) {
try (java.io.InputStream videoStream = minIOService.downloadFile(fbPost.getVideoFilename())) {
videoData = videoStream.readAllBytes();
log.info("[Facebook] Загружено видео из MinIO: {} ({} bytes)", fbPost.getVideoFilename(), videoData.length);
} catch (Exception e) {
log.warn("[Facebook] Не удалось загрузить видео {}: {}", fbPost.getVideoFilename(), e.getMessage());
}
}
byte[] imageData = null;
if (fbPost.getImageFilename() != null && !fbPost.getImageFilename().isEmpty()) {
if (videoData == null && fbPost.getImageFilename() != null && !fbPost.getImageFilename().isEmpty()) {
try (java.io.InputStream imageStream = minIOService.downloadFile(fbPost.getImageFilename())) {
imageData = imageStream.readAllBytes();
} catch (Exception e) {
@@ -1221,7 +1232,10 @@ public class MarketingStrategyV3Service {
}
String postId;
if (imageData != null && imageData.length > 0) {
if (videoData != null && videoData.length > 0) {
log.info("[Facebook] Публикую первый пост с ВИДЕО");
postId = facebookPostingService.postToPageWithVideo(fbPost.getPostText(), fbPost.getHashtags(), videoData);
} else if (imageData != null && imageData.length > 0) {
postId = facebookPostingService.postToPageWithImage(fbPost.getPostText(), fbPost.getHashtags(), imageData);
} else {
postId = facebookPostingService.postToPage(fbPost.getPostText(), fbPost.getHashtags());
@@ -137,8 +137,19 @@ public class PostingTaskService {
}
}
byte[] videoData = null;
if (task.getVideoFilename() != null && !task.getVideoFilename().isEmpty()) {
try {
java.io.InputStream videoStream = minIOService.downloadFile(task.getVideoFilename());
videoData = videoStream.readAllBytes();
logger.info("Loaded video for task {}: {} bytes", taskId, videoData.length);
} catch (Exception e) {
logger.warn("Failed to load video for task {}: {}", taskId, e.getMessage());
}
}
byte[] imageData = null;
if (task.getImageFilename() != null && !task.getImageFilename().isEmpty()) {
if (videoData == null && task.getImageFilename() != null && !task.getImageFilename().isEmpty()) {
try {
java.io.InputStream imageStream = minIOService.downloadFile(task.getImageFilename());
imageData = imageStream.readAllBytes();
@@ -151,7 +162,10 @@ public class PostingTaskService {
if ("facebook".equalsIgnoreCase(task.getPlatform())) {
if (imageData != null && imageData.length > 0) {
if (videoData != null && videoData.length > 0) {
logger.info("Publishing Facebook post WITH VIDEO for task {}", taskId);
postId = facebookPostingService.postToPageWithVideo(task.getPostText(), task.getHashtags(), videoData);
} else if (imageData != null && imageData.length > 0) {
postId = facebookPostingService.postToPageWithImage(task.getPostText(), task.getHashtags(), imageData);
} else {
postId = facebookPostingService.postToPage(task.getPostText(), task.getHashtags());