Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Mip-119 - Meeds-io/MIPs#119 #6

Merged
merged 20 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e203925
feat: Update old news webapp paths to content webapp paths - EXO-6963…
azayati Apr 2, 2024
2e50149
fix: Fix article illustration lost after draft article update - EXO-7…
sofyenne Apr 4, 2024
a19b4df
feat: Implement create article service layer - EXO-70378 - Meeds-io/M…
sofyenne Apr 4, 2024
0f652e8
feat: Implement create draft for existing article service layer - EXO…
sofyenne Apr 15, 2024
9a3d033
feat: Implement update draft for existing article service layer - EXO…
sofyenne Apr 16, 2024
be43b85
feat: Implement update article service layer - EXO-70382 - Meeds-io/M…
sofyenne Apr 19, 2024
a4ee025
feat: Update news articles delete rights - EXO-70484 - Meeds-io/MIPs#…
azayati Apr 22, 2024
73bc431
feat: Implement delete news article service layer - EXO-70383 - Meed…
sofyenne Apr 22, 2024
bde2243
feat: Implement share news service layer - EXO-70812 - Meeds-io/MIPs#…
sofyenne Apr 22, 2024
bd6a417
feat: Implement feature flag to hide schedule article and news app fi…
sofyenne Apr 24, 2024
8d92f08
fix: Some icons are not well displayed in meeds server - EXO-71197 - …
hakermi Apr 26, 2024
80dbabc
feat: Implement edit post and publishing service layer - EXO-70713 -…
sofyenne Apr 29, 2024
f170275
feat: Delete news articles when the space is deleted - EXO-71229 - Me…
sofyenne Apr 29, 2024
47b33b4
feat: Fix the post news article stepper is not displayed for the spac…
sofyenne Apr 30, 2024
706ced6
feat: Implement getDraftArticles service layer for existing articles …
hakermi Apr 30, 2024
590c093
feat: Update the publication status constant value from published to …
sofyenne May 3, 2024
a2edabd
feat: Fix news article draft for existing article not well removed af…
sofyenne May 6, 2024
fd6c596
fix: Delete Useless Loading Effectt - Meeds-io/MIPs#120 (#1173)
azayati Apr 30, 2024
06771fb
fix: Delete events listening on Vue application unmount - MEED-6224 -…
azayati Apr 30, 2024
133fc0c
fix: publish news : email received displays truncated border and cont…
azayati Apr 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import io.meeds.news.service.NewsService;
import io.meeds.news.utils.NewsUtils;

import static io.meeds.news.utils.NewsUtils.NewsObjectType.ARTICLE;

public class ActivityNewsProcessor extends BaseActivityProcessorPlugin {

private static final Log LOG = ExoLogger.getLogger(ActivityNewsProcessor.class);
Expand All @@ -58,7 +60,7 @@ public void processActivity(ExoSocialActivity activity) {
News news = (News) activity.getLinkedProcessedEntities().get("news");
if (news == null) {
try {
news = newsService.getNewsById(activity.getTemplateParams().get("newsId"), false);
news = newsService.getNewsArticleById(activity.getTemplateParams().get("newsId"));

RealtimeListAccess<ExoSocialActivity> listAccess = activityManager.getCommentsWithListAccess(activity, true);
news.setCommentsCount(listAccess.getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import io.meeds.news.service.NewsService;
import io.meeds.news.utils.NewsUtils;

import static io.meeds.news.utils.NewsUtils.NewsObjectType.ARTICLE;

/**
* A triggered listener class about activity lifecyles. This class is used to
* propagate sharing activity in News elements to let targeted space members to
Expand Down Expand Up @@ -76,8 +78,8 @@ public void shareActivity(ActivityLifeCycleEvent event) {
String newsId = originalActivity.getTemplateParams().get(NEWS_ID);
org.exoplatform.services.security.Identity currentIdentity = ConversationState.getCurrent().getIdentity();
try {
News news = newsService.getNewsById(newsId, currentIdentity, false);
if (news != null) {
News news = newsService.getNewsById(newsId, currentIdentity, false, ARTICLE.name().toLowerCase());
if (news != null && !news.isDeleted()) {
Identity posterIdentity = getIdentity(sharedActivity);
Space space = getSpace(sharedActivity);
newsService.shareNews(news, space, posterIdentity, sharedActivity.getId());
Expand Down
2 changes: 2 additions & 0 deletions content-service/src/main/java/io/meeds/news/model/News.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,6 @@ public class News {
private List<String> targets;

private boolean favorite;

private boolean deleted;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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.model;

import org.exoplatform.social.metadata.model.MetadataObject;

public class NewsLatestDraftObject extends MetadataObject {

public NewsLatestDraftObject() {
}

public NewsLatestDraftObject(String objectType, String objectId, String parentObjectId, long spaceId) {
super(objectType, objectId, parentObjectId, spaceId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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.model;

import org.exoplatform.social.metadata.model.MetadataObject;

public class NewsPageObject extends MetadataObject {

public NewsPageObject() {
}

public NewsPageObject(String objectType, String objectId, String parentObjectId, long spaceId) {
super(objectType, objectId, parentObjectId, spaceId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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.model;

import org.exoplatform.social.metadata.model.MetadataObject;

public class NewsPageVersionObject extends MetadataObject {

public NewsPageVersionObject() {
}

public NewsPageVersionObject(String objectType, String objectId, String parentObjectId, Long spaceId) {
super(objectType, objectId, parentObjectId, spaceId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class NewsTargetObject extends MetadataObject {
public NewsTargetObject() {
}

public NewsTargetObject(String objectType, String objectId, String parentObjectId) {
super(objectType, objectId, parentObjectId);
public NewsTargetObject(String objectType, String objectId, String parentObjectId, Long spaceId) {
super(objectType, objectId, parentObjectId, spaceId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected MessageInfo makeMessage(NotificationContext ctx) {
String contentSpaceName = notification.getValueOwnerParameter(NotificationConstants.CONTENT_SPACE);
String authorAvatarUrl = notification.getValueOwnerParameter(NotificationConstants.AUTHOR_AVATAR_URL);
String baseUrl = PropertyManager.getProperty("gatein.email.domain.url");
String illustrationUrl = baseUrl.concat("/news/images/newsImageDefault.png");
String illustrationUrl = baseUrl.concat("/content/images/newsImageDefault.png");
String activityLink = notification.getValueOwnerParameter(NotificationConstants.ACTIVITY_LINK);
String context = notification.getValueOwnerParameter(NotificationConstants.CONTEXT);

Expand Down Expand Up @@ -150,6 +150,7 @@ protected MessageInfo makeMessage(NotificationContext ctx) {
templateContext.put("FIRST_NAME", encoder.encode(receiver.getProfile().getProperty(Profile.FIRST_NAME).toString()));
// Footer
templateContext.put("FOOTER_LINK", LinkProviderUtils.getRedirectUrl("notification_settings", receiver.getRemoteId()));
templateContext.put("COMPANY_LINK", LinkProviderUtils.getBaseUrl());
String subject = TemplateUtils.processSubject(templateContext);
String body = TemplateUtils.processGroovy(templateContext);
// binding the exception throws by processing template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;

import static io.meeds.news.utils.NewsUtils.NewsObjectType.ARTICLE;

@Path("v1/news")
@Tag(name = "v1/news", description = "Managing news")
public class NewsRestResourcesV1 implements ResourceContainer, Startable {
Expand Down Expand Up @@ -158,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 @@ -238,6 +240,10 @@ public Response updateNews(@Parameter(description = "News id", required = true)
@Parameter(description = "News object type to be updated", required = false)
@QueryParam("type")
String newsObjectType,
@Parameter(description = "News update action type to be done", required = false)
@Schema(defaultValue = "content")
@QueryParam("newsUpdateType")
String newsUpdateType,
@RequestBody(description = "News object to be updated", required = true)
News updatedNews) {

Expand All @@ -261,11 +267,11 @@ public Response updateNews(@Parameter(description = "News id", required = true)
news.setTargets(updatedNews.getTargets());
news.setAudience(updatedNews.getAudience());

news = newsService.updateNews(news, currentIdentity.getUserId(), post, updatedNews.isPublished(), newsObjectType);
news = newsService.updateNews(news, currentIdentity.getUserId(), post, updatedNews.isPublished(), newsObjectType, newsUpdateType);

return Response.ok(news).build();
} catch (IllegalAccessException e) {
LOG.warn("User '{}' is not autorized to update news", currentIdentity.getUserId(), e);
LOG.warn("User '{}' is not authorized to update news", currentIdentity.getUserId(), e);
return Response.status(Response.Status.UNAUTHORIZED).entity(e.getMessage()).build();
} catch (Exception e) {
LOG.error("Error when updating the news " + id, e);
Expand Down Expand Up @@ -303,7 +309,7 @@ public Response deleteNews(@Context
currentIdentity,
false,
isDraft ? NewsObjectType.DRAFT.name().toLowerCase()
: NewsObjectType.ARTICLE.name().toLowerCase());
: ARTICLE.name().toLowerCase());
if (news == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
Expand Down Expand Up @@ -403,7 +409,7 @@ public Response getNewsById(@Context
}
org.exoplatform.services.security.Identity currentIdentity = ConversationState.getCurrent().getIdentity();
News news = newsService.getNewsById(id, currentIdentity, editMode, newsObjectType);
if (news == null) {
if (news == null || news.isDeleted()) {
return Response.status(Response.Status.NOT_FOUND).build();
}
Locale userLocale = LocalizationFilter.getCurrentLocale();
Expand Down Expand Up @@ -464,7 +470,7 @@ public Response markNewsAsRead(@Context
return Response.status(Response.Status.BAD_REQUEST).build();
}
org.exoplatform.services.security.Identity currentIdentity = ConversationState.getCurrent().getIdentity();
News news = newsService.getNewsById(id, currentIdentity, false);
News news = newsService.getNewsById(id, currentIdentity, false, ARTICLE.name().toLowerCase());
if (news == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
Expand Down Expand Up @@ -679,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 @@ -101,7 +101,7 @@ private Document getDocument(String id) {
LOG.debug("Index document for news id={}", id);
News news = null;
try {
news = newsService.getNewsById(id, false);
news = newsService.getNewsArticleById(id);
} catch (Exception e) {
LOG.error("Error when getting the news " + id, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public interface NewsService {
* @return updated News
* @throws Exception
*/
News updateNews(News news, String updater, Boolean post, boolean publish, String newsObjectType) throws Exception;
News updateNews(News news, String updater, Boolean post, boolean publish, String newsObjectType, String newsUpdateType) throws Exception;

/**
* Delete news
Expand Down Expand Up @@ -163,6 +163,14 @@ News getNewsById(String newsId,
boolean editMode,
String newsObjectType) throws IllegalAccessException;

/**
* Retrives a news identified by its technical identifier
*
* @param newsId {@link News} identifier
* @return {@link News} if found else null
*/
News getNewsArticleById(String newsId);

/**
* Get all news
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ void deleteTargetByName(String targetName,

/**
* Gets the {@link List} of {@link News} targets linked to a given
* {@link News} id
* {@link News}
*
* @param newsId {@link News} identifier of {@link News} targets to be
* @param news {@link News} for which targets to be
* retrieved
* @return {@link List} of {@link News} targets by {@link News} id
* @return {@link List} of {@link News} targets by {@link News} news object
*/
List<String> getTargetsByNewsId(String newsId);
List<String> getTargetsByNews(News news);

/**
* Gets the {@link List} of {@link News} target items by a given target name.
Expand Down Expand Up @@ -105,9 +105,9 @@ void deleteTargetByName(String targetName,
* Delete the {@link List} of {@link News} targets linked to a given
* {@link News} id
*
* @param newsId {@link News} identifier of {@link News} to delete targets
* @param news {@link News} for which targets to be deleted
*/
void deleteNewsTargets(String newsId);
void deleteNewsTargets(News news);

/**
* Create news target
Expand Down
Loading
Loading