-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
5,369 additions
and
1,630 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
notes-service/src/main/java/io/meeds/notes/model/NoteFeaturedImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 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.notes.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.InputStream; | ||
import java.io.Serializable; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class NoteFeaturedImage implements Serializable { | ||
|
||
private Long id; | ||
|
||
private String fileName; | ||
|
||
private String mimeType; | ||
|
||
private long fileSize; | ||
|
||
private Long lastUpdated; | ||
|
||
private String uploadId; | ||
|
||
private String altText; | ||
|
||
private transient InputStream fileInputStream; | ||
|
||
private boolean toDelete; | ||
|
||
public NoteFeaturedImage(Long id, | ||
String fileName, | ||
String mimeType, | ||
long fileSize, | ||
Long lastUpdated, | ||
InputStream fileInputStream) { | ||
this.id = id; | ||
this.fileName = fileName; | ||
this.mimeType = mimeType; | ||
this.fileSize = fileSize; | ||
this.lastUpdated = lastUpdated; | ||
this.fileInputStream = fileInputStream; | ||
} | ||
|
||
public NoteFeaturedImage(Long id, | ||
String mimeType, | ||
String uploadId, | ||
String altText, | ||
Long lastUpdated, | ||
boolean toDelete) { | ||
this.id = id; | ||
this.mimeType = mimeType; | ||
this.uploadId = uploadId; | ||
this.altText = altText; | ||
this.lastUpdated = lastUpdated; | ||
this.toDelete = toDelete; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
notes-service/src/main/java/io/meeds/notes/model/NoteMetadataObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 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, | ||
* | ||
*/ | ||
package io.meeds.notes.model; | ||
|
||
import org.exoplatform.social.metadata.model.MetadataObject; | ||
|
||
public class NoteMetadataObject extends MetadataObject { | ||
|
||
public NoteMetadataObject(String type, String id, String parentId, long spaceId) { | ||
super(type, id, parentId, spaceId); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
notes-service/src/main/java/io/meeds/notes/model/NotePageProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 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, | ||
* | ||
*/ | ||
|
||
package io.meeds.notes.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class NotePageProperties implements Serializable { | ||
|
||
private long noteId; | ||
|
||
private String summary; | ||
|
||
private NoteFeaturedImage featuredImage; | ||
|
||
private boolean isDraft; | ||
} |
115 changes: 115 additions & 0 deletions
115
...ce/src/main/java/io/meeds/notes/notifications/plugin/MentionInNoteNotificationPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 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.notes.notifications.plugin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.exoplatform.commons.api.notification.NotificationContext; | ||
import org.exoplatform.commons.api.notification.model.ArgumentLiteral; | ||
import org.exoplatform.commons.api.notification.model.NotificationInfo; | ||
import org.exoplatform.commons.api.notification.plugin.BaseNotificationPlugin; | ||
import org.exoplatform.commons.utils.CommonsUtils; | ||
import org.exoplatform.container.xml.InitParams; | ||
import org.exoplatform.services.log.ExoLogger; | ||
import org.exoplatform.services.log.Log; | ||
import org.exoplatform.services.organization.OrganizationService; | ||
import org.exoplatform.services.organization.User; | ||
import org.exoplatform.services.organization.UserHandler; | ||
import org.exoplatform.social.notification.Utils; | ||
|
||
public class MentionInNoteNotificationPlugin extends BaseNotificationPlugin { | ||
|
||
public final static String ID = "MentionInNoteNotificationPlugin"; | ||
|
||
private static final Log LOG = ExoLogger.getLogger(MentionInNoteNotificationPlugin.class); | ||
|
||
public static final ArgumentLiteral<String> CURRENT_USER = new ArgumentLiteral<>(String.class, "CURRENT_USER"); | ||
|
||
public static final ArgumentLiteral<String> NOTE_AUTHOR = new ArgumentLiteral<>(String.class, "NOTE_AUTHOR"); | ||
|
||
public static final ArgumentLiteral<String> AUTHOR_AVATAR_URL = new ArgumentLiteral<>(String.class, "AUTHOR_AVATAR_URL"); | ||
|
||
public static final ArgumentLiteral<String> AUTHOR_PROFILE_URL = new ArgumentLiteral<>(String.class, "AUTHOR_PROFILE_URL"); | ||
|
||
public static final ArgumentLiteral<String> ACTIVITY_LINK = new ArgumentLiteral<>(String.class, "ACTIVITY_LINK"); | ||
|
||
public static final ArgumentLiteral<Set> MENTIONED_IDS = new ArgumentLiteral<Set>(Set.class, "MENTIONED_IDS"); | ||
|
||
public static final ArgumentLiteral<String> NOTE_URL = new ArgumentLiteral<>(String.class, "NOTE_URL"); | ||
|
||
public static final ArgumentLiteral<String> NOTE_TITLE = new ArgumentLiteral<>(String.class, "NOTE_TITLE"); | ||
|
||
public static final ArgumentLiteral<String> SPACE_ID = new ArgumentLiteral<>(String.class, "SPACE_ID"); | ||
|
||
public MentionInNoteNotificationPlugin(InitParams initParams) { | ||
super(initParams); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public boolean isValid(NotificationContext ctx) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public NotificationInfo makeNotification(NotificationContext ctx) { | ||
String currentUserName = ctx.value(CURRENT_USER); | ||
String currentUserFullName = currentUserName; | ||
try { | ||
currentUserFullName = getUserFullName(currentUserName); | ||
} catch (Exception e) { | ||
LOG.error("An error occured when trying to retreive a user with username " + currentUserName + " " + e.getMessage(), e); | ||
} | ||
List<String> mentionedIds = new ArrayList<>(ctx.value(MENTIONED_IDS)); | ||
String spaceId = ctx.value(SPACE_ID); | ||
Set<String> receivers = new HashSet<>(); | ||
String[] mentionnedIdArray = new String[mentionedIds.size()]; | ||
Utils.sendToMentioners(receivers, mentionedIds.toArray(mentionnedIdArray), currentUserName, spaceId); | ||
return NotificationInfo.instance() | ||
.setFrom(currentUserName) | ||
.to(new ArrayList<>(receivers)) | ||
.key(getKey()) | ||
.with(NOTE_URL.getKey(), ctx.value(NOTE_URL)) | ||
.with(NOTE_TITLE.getKey(), ctx.value(NOTE_TITLE)) | ||
.with(NOTE_AUTHOR.getKey(), ctx.value(NOTE_AUTHOR)) | ||
.with(AUTHOR_AVATAR_URL.getKey(), ctx.value(AUTHOR_AVATAR_URL)) | ||
.with(AUTHOR_PROFILE_URL.getKey(), ctx.value(AUTHOR_PROFILE_URL)) | ||
.with(ACTIVITY_LINK.getKey(), ctx.value(ACTIVITY_LINK)) | ||
.with(MENTIONED_IDS.getKey(), String.valueOf(mentionedIds)) | ||
.with(CURRENT_USER.getKey(), currentUserFullName) | ||
.end(); | ||
} | ||
|
||
private String getUserFullName(String userName) throws Exception { | ||
OrganizationService organizationService = CommonsUtils.getService(OrganizationService.class); | ||
UserHandler userHandler = organizationService.getUserHandler(); | ||
User user = userHandler.findUserByName(userName); | ||
if (user == null) { | ||
throw new Exception("An error occured when trying to retreive a user with username " + userName); | ||
} | ||
return user.getFullName(); | ||
} | ||
} |
Oops, something went wrong.