Skip to content

Commit

Permalink
fix: add AltRep field for event description - EXO-73523 (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamdi authored and exo-swf committed Sep 30, 2024
1 parent 15a559c commit b337156
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.*;
import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -15,6 +16,7 @@
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.AltRep;
import net.fortuna.ical4j.model.parameter.Cn;
import net.fortuna.ical4j.model.property.*;
import net.fortuna.ical4j.util.RandomUidGenerator;
Expand Down Expand Up @@ -956,6 +958,13 @@ public static final void addIcsFile(NotificationInfo notification, MessageInfo m
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);
try {
ParameterList params = new ParameterList();
params.add(new AltRep("data:text/html," + URLEncoder.encode(htmlContent, StandardCharsets.UTF_8)));
vEvent.getProperties().add(new Description(params, plainTextContent));
} catch (Exception e) {
LOG.error("Could not add the Altrep property for description field", e);
}

/* Add event to calendar */
calendar.getComponents().add(vEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
`DTEND:${formatDate(event.endDate)}\r\n` +
`SUMMARY:${event.summary || ''}\r\n` +
`DESCRIPTION:${plainTextDescription || ''}\r\n` +
`DESCRIPTION,ALTREP:"data:text/html,${encodeURI(htmlDescription)}":${plainTextDescription}\r\n` +
`X-ALT-DESC;FMTTYPE=text/html:${htmlDescription}\r\n` +
`LOCATION:${event.location || ''}\r\n` +
`URL:${confurl}\r\n` +
Expand Down

0 comments on commit b337156

Please sign in to comment.