Skip to content

Commit

Permalink
feat: Update news articles delete rights - EXO-70484 - Meeds-io/MIPs#119
Browse files Browse the repository at this point in the history
 (#21)
  • Loading branch information
azayati committed Apr 24, 2024
1 parent 4d39f8f commit e0f759f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.exoplatform.commons.search.index.IndexingService;
import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationState;
Expand Down Expand Up @@ -179,8 +178,6 @@ public class NewsServiceImpl implements NewsService {

private final IdentityManager identityManager;

private final UserACL userACL;

private final ActivityManager activityManager;

private final WikiService wikiService;
Expand All @@ -192,7 +189,6 @@ public NewsServiceImpl(SpaceService spaceService,
NewsTargetingService newsTargetingService,
IndexingService indexingService,
IdentityManager identityManager,
UserACL userACL,
ActivityManager activityManager,
WikiService wikiService,
UploadService uploadService) {
Expand All @@ -204,7 +200,6 @@ public NewsServiceImpl(SpaceService spaceService,
this.newsTargetingService = newsTargetingService;
this.indexingService = indexingService;
this.identityManager = identityManager;
this.userACL = userACL;
this.activityManager = activityManager;
this.wikiService = wikiService;
}
Expand Down Expand Up @@ -1092,13 +1087,11 @@ private Long saveArticleIllustration(String articleUploadId, Long oldArticleIllu
}

private boolean canDeleteNews(Identity currentIdentity, String posterId, String spaceId) {
if (currentIdentity == null) {
Space space = spaceId == null ? null : spaceService.getSpaceById(spaceId);
if (space == null) {
return false;
}
String authenticatedUser = currentIdentity.getUserId();
Space currentSpace = spaceService.getSpaceById(spaceId);
return authenticatedUser.equals(posterId) || userACL.isSuperUser() || spaceService.isSuperManager(authenticatedUser)
|| spaceService.isManager(currentSpace, authenticatedUser);
return spaceService.canRedactOnSpace(space, currentIdentity);
}

private boolean isMemberOfsharedInSpaces(News news, String username) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.exoplatform.commons.search.index.IndexingService;
import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.services.security.Identity;
import org.exoplatform.social.core.manager.ActivityManager;
import org.exoplatform.social.core.manager.IdentityManager;
Expand Down Expand Up @@ -119,8 +118,6 @@ public class NewsServiceImplTest {

private NewsService newsService;

private UserACL userACL;

private static final MockedStatic<CommonsUtils> COMMONS_UTILS = mockStatic(CommonsUtils.class);

private static final MockedStatic<PortalContainer> PORTAL_CONTAINER = mockStatic(PortalContainer.class);
Expand All @@ -129,15 +126,13 @@ public class NewsServiceImplTest {

@Before
public void setUp() {
userACL = CommonsUtils.getService(UserACL.class);
this.newsService = new NewsServiceImpl(spaceService,
noteService,
metadataService,
fileService,
newsTargetingService,
indexingService,
identityManager,
userACL,
activityManager,
wikiService,
uploadService);
Expand Down

0 comments on commit e0f759f

Please sign in to comment.