Skip to content

Commit

Permalink
fix: [bug]new added images in published news are undefined after edit -
Browse files Browse the repository at this point in the history
EXO-71982

Prior to this fix,new images added to a published news are undefined for some users, this commit update images perissions wen news are updated.
  • Loading branch information
mkrout committed Oct 11, 2024
1 parent 2a28a84 commit e8450e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public class NewsServiceImpl implements NewsService {

private static final String NEWS_ID = "newsId";

public static final String NEWS_ATTACHMENTS_IDS = "attachmentsIds";

public static final String ARTICLE_CONTENT = "content";

public static final String NEWS_AUDIENCE = "audience";

public SpaceService spaceService;

private ActivityManager activityManager;
Expand Down Expand Up @@ -204,7 +210,9 @@ public News updateNews(News news, String updater, Boolean post, boolean publish)
if (post != null) {
updateNewsActivity(news, post);
}
NewsUtils.broadcastEvent(NewsUtils.UPDATE_NEWS, updater, news);
NewsUtils.broadcastEvent(NewsUtils.UPDATE_NEWS, updater, news);
Space space = spaceService.getSpaceById(news.getSpaceId());
updateArticlePermissions(List.of(space), news, null);
}
return news;
}
Expand Down Expand Up @@ -730,4 +738,16 @@ private boolean isMemberOfsharedInSpaces(News news, String username) {
}
return false;
}
private void updateArticlePermissions(List<Space> spaces, News article, List<String> articleAttachmentIds) {
Map<String, Object> updateContentPermissionEventListenerData = new HashMap<>();
updateContentPermissionEventListenerData.putAll(Map.of("spaces", spaces, ARTICLE_CONTENT, article.getBody()));
if (articleAttachmentIds != null) {
updateContentPermissionEventListenerData.put(NEWS_ATTACHMENTS_IDS, articleAttachmentIds);
}

if (article.getAudience() != null) {
updateContentPermissionEventListenerData.put(NEWS_AUDIENCE, article.getAudience());
}
NewsUtils.broadcastEvent(NewsUtils.UPDATE_CONTENT_PERMISSIONS, this, updateContentPermissionEventListenerData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class NewsUtils {
private static final String MANAGER_MEMBERSHIP_NAME = "manager";

private static final String PLATFORM_WEB_CONTRIBUTORS_GROUP = "/platform/web-contributors";

public static final String UPDATE_CONTENT_PERMISSIONS = "content.update.permissions";

public static void broadcastEvent(String eventName, Object source, Object data) {
try {
Expand Down

0 comments on commit e8450e8

Please sign in to comment.