feat:#49 switch to new branch for ical altrep

This commit is contained in:
Elmar Kresse
2024-10-15 14:59:33 +02:00
parent c00990dd8e
commit b8dd4338b3
3 changed files with 12 additions and 162 deletions

View File

@@ -33,10 +33,14 @@ func generateUserAgentSpecificDescription(vEvent *ics.VEvent, event model.Event,
if isThunderbird(userAgent) && altrep != "" {
// Thunderbird-specific handling: Add DESCRIPTION with ALTREP attribute.
// create property altrep
altrepParam := WithAltRep(altrep)
//altrepParam := WithAltRep(altrep)
vEvent.AddProperty(ics.ComponentPropertyDescription, description, altrepParam)
AddProperty(ics.ComponentPropertyDescription, description, altrepParam, vEvent)
uri := &url.URL{
Scheme: "data",
Opaque: altrep,
}
vEvent.AddProperty(ics.ComponentPropertyDescription, description, ics.WithAlternativeRepresentation(uri))
} else {
// Default handling: Add plain DESCRIPTION property for other user agents.
vEvent.AddProperty("DESCRIPTION", description)
@@ -44,23 +48,6 @@ func generateUserAgentSpecificDescription(vEvent *ics.VEvent, event model.Event,
}
func AddProperty(property ics.ComponentProperty, value string, prop ics.PropertyParameter, cb *ics.VEvent) {
baseProperty := &ics.BaseProperty{
IANAToken: string(property),
Value: value,
ICalParameters: map[string][]string{},
}
customProperty := NewCustomProperty(*baseProperty)
r := ics.IANAProperty{
BaseProperty: customProperty,
}
k, v := prop.KeyValue()
r.ICalParameters[k] = v
cb.Properties = append(cb.Properties, r)
}
// Generates description based on the event details and user agent.
func generateDescription(event model.Event, userAgent string) (string, string) {
plainDescription := buildPlainTextDescription(event)
@@ -68,7 +55,7 @@ func generateDescription(event model.Event, userAgent string) (string, string) {
if isThunderbird(userAgent) {
// Thunderbird-specific: Generate HTML and ALTREP format for Thunderbird users.
htmlDescription := generateThunderbirdHTMLDescription(event)
altrep := `"data:text/html,` + url.PathEscape(htmlDescription) + `"`
altrep := `text/html,` + url.PathEscape(htmlDescription)
return plainDescription, altrep
}