Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Implement the administration management of automatic translation for news - EXO-72353 - Meeds-io/MIPs#129 (#225)

feat: Add the newsServices as a prototype in the favorite drawer extension - EXO-74122 - Meeds-io/MIPs#129 (#229)

feat: Implement consult news action menu revamping - EXO-73149 - Meeds-io/MIPs#129 (#228)

feat: Implement article copy link action - EXO-73602 - Meeds-io/MIPs#129 (#230)

feat: Disable the save/publish button when draft status is saving - EXO-74280 - Meeds-io/MIPs#129 (#235)

feat: Fix content body inserted images permissions - EXO-74263_EXO-74265_EXO-74266 - Meeds-io/MIPs#129 (#240)

fix: Fix displaying content detail for public sites - EXO-74419 - Meeds-io/MIPs#129 (#243)

feat: Implement Space news target auto creation listener in order to create space news target when a space is created - EXO-73039 - Meeds-io/MIPs#129 (#245)

feat: Remove unread activities notifications channel for PublishNewsNotificationPlugin - EXO-73048 - Meeds-io/MIPs#129 (#252)

feat: Remove unread activities notifications channel for MentionInNewsNotificationPlugin - EXO-73152 - Meeds-io/MIPs#129 (#253)

feat: Send published article public link in publish news mail notification message - EXO-73050 - Meeds-io/MIPs#129 (#255)

feat: Implement new article view layout - EXO-73043 - Meeds-io/MIPs#129 (#256)

Implement new article view layout
  • Loading branch information
sofyenne authored and azayati committed Oct 11, 2024
1 parent 30aae10 commit 36272c3
Show file tree
Hide file tree
Showing 40 changed files with 1,240 additions and 1,535 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.meeds.news.listener;

import java.util.Map;

import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.services.security.Identity;
import org.exoplatform.social.core.space.SpaceListenerPlugin;
import org.exoplatform.social.core.space.model.Space;
import org.exoplatform.social.core.space.spi.SpaceLifeCycleEvent;

import io.meeds.news.rest.NewsTargetingEntity;
import io.meeds.news.service.NewsTargetingService;

public class SpaceNewsTargetAutoCreationListener extends SpaceListenerPlugin {

private static final Log LOG =
ExoLogger.getLogger(SpaceNewsTargetAutoCreationListener.class);

private NewsTargetingService newsTargetingService;

private static final String SPACE_NEWS_TARGET_AUTO_CREATION_FEATURE = "spaceNewsTargetAutoCreation";

public SpaceNewsTargetAutoCreationListener(NewsTargetingService newsTargetingService) {
this.newsTargetingService = newsTargetingService;
}

@Override
public void spaceCreated(SpaceLifeCycleEvent event) {
if (CommonsUtils.isFeatureActive(SPACE_NEWS_TARGET_AUTO_CREATION_FEATURE)) {
Identity currentIdentity = ConversationState.getCurrent().getIdentity();
Space space = event.getSpace();
NewsTargetingEntity spaceNewsTargetEntity = new NewsTargetingEntity();
spaceNewsTargetEntity.setName(space.getDisplayName());
spaceNewsTargetEntity.setProperties(Map.of("label", space.getDisplayName(), "permissions", "space:" + space.getId()));
try {
newsTargetingService.createNewsTarget(spaceNewsTargetEntity, currentIdentity, false);
} catch (Exception e) {
LOG.warn("Can't create space {} news target", space.getPrettyName());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ protected MessageInfo makeMessage(NotificationContext ctx) {
templateContext.put("AUTHOR_AVATAR_URL", encoder.encode(authorAvatarUrl));
templateContext.put("CONTEXT", encoder.encode(context));
StringBuilder activityUrl = new StringBuilder();
Space space = spaceService.getSpaceByDisplayName(contentSpaceName);
if (pluginId.equals(PublishNewsNotificationPlugin.ID) && !spaceService.isMember(space, notification.getTo())) {
if (pluginId.equals(PublishNewsNotificationPlugin.ID)) {
String portalName = PortalContainer.getCurrentPortalContainerName();
String portalOwner = CommonsUtils.getCurrentPortalOwner();
String currentDomain = CommonsUtils.getCurrentDomain();
Expand Down
93 changes: 46 additions & 47 deletions content-service/src/main/java/io/meeds/news/rest/NewsRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ public class NewsRest {

private ScheduledExecutorService scheduledExecutor;

private static final int CACHE_DURATION_SECONDS = 31536000;

private enum FilterType {
PINNED, MYPOSTED, DRAFTS, SCHEDULED, ALL
}
Expand Down Expand Up @@ -750,51 +748,6 @@ public ResponseEntity<Boolean> canPublishNews(@RequestParam(name = "spaceId", re
}
}

private NewsFilter buildFilter(List<String> spaces, String filter, String text, String author, int limit, int offset) {
NewsFilter newsFilter = new NewsFilter();

newsFilter.setSpaces(spaces);
if (StringUtils.isNotEmpty(filter)) {
FilterType filterType = FilterType.valueOf(filter.toUpperCase());
switch (filterType) {
case PINNED: {
newsFilter.setPublishedNews(true);
break;
}

case MYPOSTED: {
if (StringUtils.isNotEmpty(author)) {
newsFilter.setAuthor(author);
}
break;
}
case DRAFTS: {
if (StringUtils.isNotEmpty(author)) {
newsFilter.setAuthor(author);
}
newsFilter.setDraftNews(true);
break;
}
case SCHEDULED: {
if (StringUtils.isNotEmpty(author)) {
newsFilter.setAuthor(author);
}
newsFilter.setScheduledNews(true);
break;
}
}
newsFilter.setOrder("UPDATED_DATE");
}
// Set text to search news with
if (StringUtils.isNotEmpty(text) && text.indexOf("#") != 0) {
newsFilter.setSearchText(text);
}
newsFilter.setLimit(limit);
newsFilter.setOffset(offset);

return newsFilter;
}

@DeleteMapping(path = "translation/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Secured("users")
@Operation(summary = "Delete article version with language", method = "DELETE", description = "This deletes the article version ")
Expand Down Expand Up @@ -859,4 +812,50 @@ public ResponseEntity<List<String>> getAvailableTranslationLanguages(@PathVariab
return ResponseEntity.internalServerError().build();
}
}

private NewsFilter buildFilter(List<String> spaces, String filter, String text, String author, int limit, int offset) {
NewsFilter newsFilter = new NewsFilter();

newsFilter.setSpaces(spaces);
if (StringUtils.isNotEmpty(filter)) {
FilterType filterType = FilterType.valueOf(filter.toUpperCase());
switch (filterType) {
case PINNED: {
newsFilter.setPublishedNews(true);
break;
}

case MYPOSTED: {
if (StringUtils.isNotEmpty(author)) {
newsFilter.setAuthor(author);
}
break;
}
case DRAFTS: {
if (StringUtils.isNotEmpty(author)) {
newsFilter.setAuthor(author);
}
newsFilter.setDraftNews(true);
break;
}
case SCHEDULED: {
if (StringUtils.isNotEmpty(author)) {
newsFilter.setAuthor(author);
}
newsFilter.setScheduledNews(true);
break;
}
}
newsFilter.setOrder("UPDATED_DATE");
}
// Set text to search news with
if (StringUtils.isNotEmpty(text) && text.indexOf("#") != 0) {
newsFilter.setSearchText(text);
}
newsFilter.setLimit(limit);
newsFilter.setOffset(offset);

return newsFilter;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,11 @@ News createDraftArticleForNewPage(News draftArticle,
* @param updater
* @param page
* @param creationDate
* @param space
* @return the created news draft for an existing news article
* @throws Exception when error occurs
*/
News createDraftForExistingPage(News news, String updater, Page page, long creationDate) throws Exception;
News createDraftForExistingPage(News news, String updater, Page page, long creationDate, Space space) throws Exception;

/**
* @param news {@link News} news article to be deleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void deleteTargetByName(String targetName,
* Gets the {@link List} of {@link News} targets linked to a given
* {@link News}
*
* @param news {@link News} for which targets to be
* retrieved
* @param news {@link News} for which targets to be retrieved
* @return {@link List} of {@link News} targets by {@link News} news object
*/
List<String> getTargetsByNews(News news);
Expand Down Expand Up @@ -127,6 +126,23 @@ Metadata createNewsTarget(NewsTargetingEntity newsTargetingEntity,
org.exoplatform.services.security.Identity currentIdentity) throws IllegalArgumentException,
IllegalAccessException;

/**
* Create news target
*
* @param newsTargetingEntity {@link News} TargetingEntity
* @param currentIdentity current {@link Identity} attempting to create
* {@link News} target
* @param checkPermissions true if permissions are checked
* @return created {@link News} target {@link Metadata}
* @throws IllegalArgumentException when user creates a {@link News} target
* that already exists
* @throws IllegalAccessException when user doesn't have access to create
* {@link News} target
*/
Metadata createNewsTarget(NewsTargetingEntity newsTargetingEntity,
org.exoplatform.services.security.Identity currentIdentity,
boolean checkPermissions) throws IllegalArgumentException, IllegalAccessException;

/**
* Update news target
*
Expand Down
Loading

0 comments on commit 36272c3

Please sign in to comment.