From 8375449a2e60573d72a29eb22a8a9b6b88ffacc6 Mon Sep 17 00:00:00 2001 From: Helmi Akermi <70575401+hakermi@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:40:03 +0100 Subject: [PATCH] feat: Adjust publish article from existing note permissions - EXO-75520 - Meeds-io/MIPs#161 (#323) Adjust publish article from existing note permissions --- .../java/io/meeds/news/service/impl/NewsServiceImpl.java | 3 ++- .../note-publish-extensions/extensions.js | 2 +- .../src/main/webapp/vue-app/services/newsServices.js | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/content-service/src/main/java/io/meeds/news/service/impl/NewsServiceImpl.java b/content-service/src/main/java/io/meeds/news/service/impl/NewsServiceImpl.java index 1df3c92d1..51d38f85c 100644 --- a/content-service/src/main/java/io/meeds/news/service/impl/NewsServiceImpl.java +++ b/content-service/src/main/java/io/meeds/news/service/impl/NewsServiceImpl.java @@ -816,7 +816,8 @@ public List search(org.exoplatform.social.core.identity.mode @Override public boolean canScheduleNews(Space space, Identity currentIdentity, News article) { boolean isArticleAuthor = article.getAuthor() != null && article.getAuthor().equals(currentIdentity.getUserId()); - boolean spaceMemberCanSchedule = isArticleAuthor && spaceService.isMember(space, currentIdentity.getUserId()); + boolean spaceMemberCanSchedule = (article.isFromExternalPage() || isArticleAuthor) + && spaceService.isMember(space, currentIdentity.getUserId()); return spaceMemberCanSchedule || spaceService.isManager(space, currentIdentity.getUserId()) || spaceService.isRedactor(space, currentIdentity.getUserId()) || NewsUtils.canPublishNews(space.getId(), currentIdentity); diff --git a/content-webapp/src/main/webapp/vue-app/news-extensions/note-publish-extensions/extensions.js b/content-webapp/src/main/webapp/vue-app/news-extensions/note-publish-extensions/extensions.js index 0e233d7d4..576b37225 100644 --- a/content-webapp/src/main/webapp/vue-app/news-extensions/note-publish-extensions/extensions.js +++ b/content-webapp/src/main/webapp/vue-app/news-extensions/note-publish-extensions/extensions.js @@ -6,7 +6,7 @@ export function initPublishExtension(params) { sortable: true, cssClass: 'ps-2 pe-4 action-menu-item', rank: 30, - enabled: (note) => eXo?.env?.portal?.notePublicationEnabled && !note.draftPage, + enabled: (note) => eXo?.env?.portal?.notePublicationEnabled && !note.draftPage && note.canManage, action: (vm) => { vm.$root.$emit('open-publish-drawer', { savedSettings: params.savedSettings, diff --git a/content-webapp/src/main/webapp/vue-app/services/newsServices.js b/content-webapp/src/main/webapp/vue-app/services/newsServices.js index 4dbf000cd..0d2cf4551 100644 --- a/content-webapp/src/main/webapp/vue-app/services/newsServices.js +++ b/content-webapp/src/main/webapp/vue-app/services/newsServices.js @@ -223,7 +223,14 @@ export function canScheduleNews(spaceId, articleId) { 'Content-Type': 'application/json' }, method: 'GET' - }).then((resp) => resp && resp.ok && resp.json()); + }).then((response) => { + if (!response?.ok) { + throw response; + } + return response.json(); + }).catch(err => { + throw err; + }); } export function deleteNews(newsId, newsObjectType, delay) {