-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Conducted UI review for the agenda event details body - Better ICS file generation on the server side and eventtitle only as subject if creator or updater
- Loading branch information
Showing
10 changed files
with
97 additions
and
29 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
import net.fortuna.ical4j.data.CalendarOutputter; | ||
import net.fortuna.ical4j.model.DateTime; | ||
import net.fortuna.ical4j.model.ParameterList; | ||
import net.fortuna.ical4j.model.component.VEvent; | ||
import net.fortuna.ical4j.model.parameter.Cn; | ||
import net.fortuna.ical4j.model.property.*; | ||
|
@@ -52,6 +53,7 @@ | |
import org.exoplatform.webui.utils.TimeConvertUtils; | ||
|
||
import static org.exoplatform.agenda.util.Utils.getICalTimeZone; | ||
import static org.exoplatform.agenda.util.Utils.getResourceBundleLabel; | ||
|
||
public class NotificationUtils { | ||
|
||
|
@@ -848,7 +850,7 @@ private static final String getEventNotificationCreatorOrModifierUserName(Identi | |
.map(t -> t.substring(0, 1).toUpperCase() + t.substring(1)) | ||
.collect(Collectors.joining(" ")); | ||
if(Utils.isExternal(identity.getRemoteId())) { | ||
fullName += " " + "(" + Utils.getResourceBundleLabel(new Locale(Utils.getUserLanguage(identity.getRemoteId())), "external.label.tag") + ")"; | ||
fullName += " " + "(" + getResourceBundleLabel(new Locale(Utils.getUserLanguage(identity.getRemoteId())), "external.label.tag") + ")"; | ||
} | ||
return fullName; | ||
} | ||
|
@@ -898,12 +900,21 @@ public static String getWebConferenceLink(Event event) { | |
|
||
} | ||
public static final void addIcsFile(NotificationInfo notification, MessageInfo messageInfo, ZoneId timeZone) { | ||
Attachment attachment = new Attachment(); | ||
IdentityManager identityManager = ExoContainerContext.getService(IdentityManager.class); | ||
SpaceService spaceService = ExoContainerContext.getService(SpaceService.class); | ||
String ownerId = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_OWNER_ID); | ||
Identity identity = identityManager.getIdentity(ownerId); | ||
Space space = identity!=null ? spaceService.getSpaceByPrettyName(identity.getRemoteId()) : null; | ||
String spaceName = space == null ? null : space.getDisplayName(); | ||
String eventConference = notification.getValueOwnerParameter(TEMPLATE_VARIABLE_EVENT_CONFERENCE); | ||
String eventCreator = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_CREATOR); | ||
Attachment attachment = new Attachment(); | ||
/* Generate unique identifier */ | ||
UidGenerator ug = new RandomUidGenerator(); | ||
Uid uid = ug.generateUid(); | ||
/* Create the event */ | ||
String eventSummary = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_TITLE); | ||
String eventDescription = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_DESCRIPTION); | ||
String startDateRFC3339 = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_START_DATE); | ||
String endDateRFC3339 = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_END_DATE); | ||
ZonedDateTime startDate = ZonedDateTime.parse(startDateRFC3339).withZoneSameInstant(timeZone); | ||
|
@@ -919,8 +930,33 @@ public static final void addIcsFile(NotificationInfo notification, MessageInfo m | |
calendar.getProperties().add(Version.VERSION_2_0); | ||
calendar.getProperties().add(CalScale.GREGORIAN); | ||
Organizer organizer = new Organizer(URI.create("[email protected]")); | ||
organizer.getParameters().add(new Cn(notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_CREATOR))); | ||
organizer.getParameters().add(new Cn(eventCreator)); | ||
calendar.getProperties().add(organizer); | ||
|
||
Locale userLocale = Locale.of(Utils.getUserLanguage(notification.getTo())); | ||
String plainTextContent = getResourceBundleLabel(userLocale, "agenda.invitationText") + " " + eventCreator + | ||
" " + getResourceBundleLabel(userLocale, "agenda.inSpace") + " " + spaceName + ". \n" | ||
+ (eventConference != null ? getResourceBundleLabel(userLocale, "agenda.visioLink") + " " + eventConference : ""); | ||
String htmlContent = "<html><body>" + | ||
getResourceBundleLabel(userLocale, "agenda.invitationText") + " " + " <b>" + eventCreator | ||
+ "</b> " + getResourceBundleLabel(userLocale, "agenda.inSpace") + " <b>" + spaceName + "</b>. " | ||
+ ( eventConference != null ? "<br><b>" + getResourceBundleLabel(userLocale, "agenda.visioLink") + " " + "</b> " | ||
+ "<a href=\""+ eventConference + "\">" | ||
+ eventConference + "</a>" :""); | ||
if (eventDescription != null && !eventDescription.isEmpty()) { | ||
plainTextContent = plainTextContent + "\n \n " + getResourceBundleLabel(userLocale, "agenda.eventDetail") + ": \n" + | ||
eventDescription.replaceAll("<a\\s+href=\"([^\"]+)\"[^>]*>(.*?)</a>", "$2 ($1)") | ||
.replaceAll("</?[^>]+(>|$)", "") | ||
.replaceAll("\\n{2,}", "\n").trim(); | ||
htmlContent = htmlContent + "<br><br>" + getResourceBundleLabel(userLocale, "agenda.eventDetail") + "<br>" + eventDescription; | ||
} | ||
vEvent.getProperties().add(new Description(plainTextContent)); | ||
htmlContent = htmlContent + "</body></html>"; | ||
ParameterList parameters = new ParameterList(); | ||
parameters.add(new net.fortuna.ical4j.model.parameter.XParameter("FMTTYPE", "text/html")); | ||
XProperty xProperty = new XProperty("X-ALT-DESC", parameters, htmlContent); | ||
vEvent.getProperties().add(xProperty); | ||
|
||
/* Add event to calendar */ | ||
calendar.getComponents().add(vEvent); | ||
CalendarOutputter outputter = new CalendarOutputter(); | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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