Fixes
This commit is contained in:
parent
1569114593
commit
6158707daa
2 changed files with 14 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -236,8 +237,16 @@ public class ActivityPubController {
|
||||||
noteObject.put("conversation", activityUri);
|
noteObject.put("conversation", activityUri);
|
||||||
|
|
||||||
// Add activity image if available
|
// Add activity image if available
|
||||||
String imageUrl = activityImageService.getActivityImageUrl(activity);
|
// Check if image exists, otherwise generate it
|
||||||
if (imageUrl != null) {
|
File imageFile = activityImageService.getActivityImageFile(activity.getId());
|
||||||
|
if (!imageFile.exists()) {
|
||||||
|
// Generate image if it doesn't exist
|
||||||
|
activityImageService.generateActivityImage(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only add attachment if image was successfully generated/exists
|
||||||
|
if (imageFile.exists()) {
|
||||||
|
String imageUrl = baseUrl + "/api/activities/" + activity.getId() + "/image";
|
||||||
Map<String, Object> imageAttachment = new HashMap<>();
|
Map<String, Object> imageAttachment = new HashMap<>();
|
||||||
imageAttachment.put("type", "Image");
|
imageAttachment.put("type", "Image");
|
||||||
imageAttachment.put("mediaType", "image/png");
|
imageAttachment.put("mediaType", "image/png");
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,11 @@ import org.operaton.fitpub.model.entity.User;
|
||||||
import org.operaton.fitpub.repository.ActivityRepository;
|
import org.operaton.fitpub.repository.ActivityRepository;
|
||||||
import org.operaton.fitpub.repository.UserRepository;
|
import org.operaton.fitpub.repository.UserRepository;
|
||||||
import org.operaton.fitpub.security.JwtTokenProvider;
|
import org.operaton.fitpub.security.JwtTokenProvider;
|
||||||
|
import org.operaton.fitpub.config.TestcontainersConfiguration;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockMultipartFile;
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
|
@ -37,6 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@ActiveProfiles("test")
|
@ActiveProfiles("test")
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@Import(TestcontainersConfiguration.class)
|
||||||
class ActivityControllerIntegrationTest {
|
class ActivityControllerIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue