diff --git a/main.go b/main.go index 4cef663..44640b6 100644 --- a/main.go +++ b/main.go @@ -193,8 +193,8 @@ func redactMessage(client *mautrix.Client, ctx context.Context, evt *event.Event if !config.mngtRoomReports { return } - message := fmt.Sprintf("Message redacted - %s:
%s
", reason, evt.Content.AsMessage().Body) - rawMessage := fmt.Sprintf("Message redacted - %s:%s", reason, evt.Content.AsMessage().Body) + message := getRedactNotice(reason, evt) + rawMessage := getRawRedactNotice(reason, evt) contentJson := &event.MessageEventContent{ MsgType: event.MsgNotice, Format: event.FormatHTML, @@ -207,6 +207,22 @@ func redactMessage(client *mautrix.Client, ctx context.Context, evt *event.Event } } +func getRedactNotice(reason string, evt *event.Event) string { + roomId := evt.RoomID.String() + userId := evt.Sender.String() + template := "Message redacted - %s;
" + + "User %s in room %s :
" + + "
%s
" + return fmt.Sprintf(template, reason, userId, userId, roomId, roomId, evt.Content.AsMessage().Body) +} + +func getRawRedactNotice(reason string, evt *event.Event) string { + roomId := evt.RoomID.String() + userId := evt.Sender.String() + template := "Message redacted - %s; User '%s' in room '%s': %s" + return fmt.Sprintf(template, reason, userId, roomId, evt.Content.AsMessage().Body) +} + func onRoomInvite(ctx context.Context, evt *event.Event) { if evt.GetStateKey() == client.UserID.String() && evt.Content.AsMember().Membership == event.MembershipInvite { _, err := client.JoinRoomByID(ctx, evt.RoomID)