Skip to content

Commit 6b5eae6

Browse files
committed
fix: improve placeholder email when KeepAttendees is used
With Google Calendar, DisplayName does not work correctly. Therefore this works as a workaround to better see the attendees.
1 parent 803b112 commit 6b5eae6

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

internal/transformation/keepAttendees.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package transformation
33
import (
44
"fmt"
55
"net/mail"
6+
"strings"
67

78
"github.com/inovex/CalendarSync/internal/models"
89
)
@@ -28,16 +29,15 @@ func (t *KeepAttendees) Transform(source models.Event, sink models.Event) (model
2829
}
2930

3031
var email = sourceAttendee.Email
31-
// Hashing the email and creating the new email to use
32-
emailHashedAndTransformed := fmt.Sprintf("%s@localhost", fmt.Sprint(models.Hash(email)))
32+
emailTransformed := fmt.Sprintf("%s@localhost", fmt.Sprint(strings.ReplaceAll(email, "@", "_")))
3333

34-
if _, err := mail.ParseAddress(emailHashedAndTransformed); err != nil {
35-
return models.Event{}, fmt.Errorf("no valid email address %s: %w", emailHashedAndTransformed, err)
34+
if _, err := mail.ParseAddress(emailTransformed); err != nil {
35+
return models.Event{}, fmt.Errorf("no valid email address %s: %w", emailTransformed, err)
3636
}
3737

3838
sinkAttendees = append(sinkAttendees, models.Attendee{
3939
DisplayName: displayName,
40-
Email: emailHashedAndTransformed,
40+
Email: emailTransformed,
4141
})
4242
}
4343
sink.Attendees = sinkAttendees

internal/transformation/keepAttendees_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package transformation
22

33
import (
4-
"fmt"
54
"testing"
65

76
"github.com/stretchr/testify/assert"
@@ -42,11 +41,11 @@ func TestKeepAttendeesWithAnonymousEmail(t *testing.T) {
4241
Attendees: []models.Attendee{
4342
{
4443
DisplayName: "Foo",
45-
Email: fmt.Sprintf("%s@localhost", fmt.Sprint(models.Hash("foo@example.com"))),
44+
Email: "foo_example.com@localhost",
4645
},
4746
{
4847
DisplayName: "Bar",
49-
Email: fmt.Sprintf("%s@localhost", fmt.Sprint(models.Hash("bar@example.com"))),
48+
Email: "bar_example.com@localhost",
5049
},
5150
},
5251
}
@@ -88,11 +87,11 @@ func TestKeepAttendeesWithEmailAsDisplayName(t *testing.T) {
8887
Attendees: []models.Attendee{
8988
{
9089
DisplayName: "foo@example.com",
91-
Email: fmt.Sprintf("%s@localhost", fmt.Sprint(models.Hash("foo@example.com"))),
90+
Email: "foo_example.com@localhost",
9291
},
9392
{
9493
DisplayName: "bar@example.com",
95-
Email: fmt.Sprintf("%s@localhost", fmt.Sprint(models.Hash("bar@example.com"))),
94+
Email: "bar_example.com@localhost",
9695
},
9796
},
9897
}

0 commit comments

Comments
 (0)