Skip to content

Commit

Permalink
feat: Update the publication status constant value from published to …
Browse files Browse the repository at this point in the history
…posted for the posted news articles - EXO-71505 - Meeds-io/MIPs#119 (#46)
  • Loading branch information
sofyenne committed May 3, 2024
1 parent 4c8c13c commit 3c77be7
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void stop() {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("users")
@Operation(summary = "Create a news", method = "POST", description = "This creates the news if the authenticated user is a member of the space or a spaces super manager. The news is created in draft status, unless the publicationState property is set to 'published'.")
@Operation(summary = "Create a news", method = "POST", description = "This creates the news if the authenticated user is a member of the space or a spaces super manager. The news is created in draft status, unless the publicationState property is set to 'posted'.")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "News created"),
@ApiResponse(responseCode = "400", description = "Invalid query input"),
@ApiResponse(responseCode = "401", description = "User not authorized to create the news"),
Expand Down Expand Up @@ -685,7 +685,7 @@ public Response getNewsByActivityId(@Parameter(description = "Activity id", requ
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("users")
@Operation(summary = "Schedule a news", method = "POST", description = "This schedules the news if the authenticated user is a member of the space or a spaces super manager. The news is created in staged status, after reaching a date of publication startPublishedDate, the publicationState property is set to 'published'.")
@Operation(summary = "Schedule a news", method = "POST", description = "This schedules the news if the authenticated user is a member of the space or a spaces super manager. The news is created in staged status, after reaching a date of publication startPublishedDate, the publicationState property is set to 'posted'.")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "News scheduled"),
@ApiResponse(responseCode = "400", description = "Invalid query input"),
@ApiResponse(responseCode = "401", description = "User not authorized to schedule the news"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public class NewsServiceImpl implements NewsService {
/** The Constant PUBLISHED. */
public final static String PUBLISHED = "published";

/** The Constant POSTED. */
public final static String POSTED = "posted";

/** The Constant DRAFT. */
public final static String DRAFT = "draft";

Expand Down Expand Up @@ -225,7 +228,7 @@ public News createNews(News news, Identity currentIdentity) throws Exception {
throw new IllegalAccessException("User " + currentIdentity.getUserId() + " not authorized to create news");
}
News createdNews;
if (PUBLISHED.equals(news.getPublicationState())) {
if (POSTED.equals(news.getPublicationState())) {
createdNews = postNews(news, currentIdentity.getUserId());
} else if (news.getSchedulePostDate() != null) {
createdNews = unScheduleNews(news, currentIdentity);
Expand Down Expand Up @@ -314,7 +317,7 @@ public News updateNews(News news, String updater, Boolean post, boolean publish,
news = updateNewsArticle(news, updaterIdentity, newsUpdateType);
}

if (PUBLISHED.equals(news.getPublicationState())) {
if (POSTED.equals(news.getPublicationState())) {
// Send mention notifs
if (StringUtils.isNotEmpty(news.getId()) && news.getCreationDate() != null) {
News newMentionedNews = news;
Expand Down Expand Up @@ -719,12 +722,12 @@ public boolean canViewNews(News news, String authenticatedUser) {
LOG.warn("Can't find space with id {} when checking access on news with id {}", spaceId, news.getId());
return false;
}
if (!news.isPublished() && StringUtils.equals(news.getPublicationState(), PUBLISHED)
if (!news.isPublished() && StringUtils.equals(news.getPublicationState(), POSTED)
&& !(spaceService.isSuperManager(authenticatedUser) || spaceService.isMember(space, authenticatedUser)
|| isMemberOfsharedInSpaces(news, authenticatedUser))) {
return false;
}
if (news.isPublished() && StringUtils.equals(news.getPublicationState(), PUBLISHED) && news.getAudience().equals(NewsUtils.SPACE_NEWS_AUDIENCE)
if (news.isPublished() && StringUtils.equals(news.getPublicationState(), POSTED) && news.getAudience().equals(NewsUtils.SPACE_NEWS_AUDIENCE)
&& !(spaceService.isMember(space, authenticatedUser) || isMemberOfsharedInSpaces(news, authenticatedUser))) {
return false;
}
Expand Down
Loading

0 comments on commit 3c77be7

Please sign in to comment.