Skip emails with incorrect email when export ics file (#5190)
<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
e6dd387811
commit
9c8ac96aed
@ -5,6 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/mail"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
@ -279,6 +280,12 @@ func isASCII(s string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Checks if a given string is a valid email address
|
||||
func isEmail(em string) bool {
|
||||
_, err := mail.ParseAddress(em)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func updateEventProperties(ctx context.Context, event models.Eventable, iCalEvent *ics.VEvent) error {
|
||||
// CREATED - https://www.rfc-editor.org/rfc/rfc5545#section-3.8.7.1
|
||||
created := event.GetCreatedDateTime()
|
||||
@ -481,8 +488,21 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven
|
||||
}
|
||||
}
|
||||
|
||||
// It is possible that we get non email items like the below
|
||||
// one which is an internal representation of the user in the
|
||||
// Exchange system. While we can technically output this as an
|
||||
// attendee, it is not useful plus other downstream tools like
|
||||
// ones to use PST can choke on this.
|
||||
// /o=ExchangeLabs/ou=ExchangeAdministrative Group(FY...LT)/cn=Recipients/cn=883...4a-John Doe
|
||||
addr := ptr.Val(attendee.GetEmailAddress().GetAddress())
|
||||
iCalEvent.AddAttendee(addr, props...)
|
||||
if isEmail(addr) {
|
||||
iCalEvent.AddAttendee(addr, props...)
|
||||
} else {
|
||||
logger.Ctx(ctx).
|
||||
With("attendee_email", addr).
|
||||
With("attendee_name", name).
|
||||
Info("skipping non email attendee from ics export")
|
||||
}
|
||||
}
|
||||
|
||||
// LOCATION - https://www.rfc-editor.org/rfc/rfc5545#section-3.8.1.7
|
||||
|
||||
@ -908,6 +908,17 @@ func (suite *ICSUnitSuite) TestAttendees() {
|
||||
"attendee")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "attendee with internal exchange representation for email",
|
||||
att: [][]string{{
|
||||
"/o=ExchangeLabs/ou=ExchangeAdministrative Group(FY...LT)/cn=Recipients/cn=883...4a-John Doe",
|
||||
"required",
|
||||
"declined",
|
||||
}},
|
||||
check: func(out string) {
|
||||
assert.NotContains(t, out, "ATTENDEE")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "multiple attendees",
|
||||
att: [][]string{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user