automatically ignore known forwarded addresses, fixes #64

This commit is contained in:
Aine
2023-09-18 12:35:37 +03:00
parent e90925eceb
commit 60b4386dd8
187 changed files with 4070 additions and 2667 deletions

View File

@@ -42,6 +42,12 @@ type BeeperMessageStatusEventContent struct {
LastRetry id.EventID `json:"last_retry,omitempty"`
MutateEventKey string `json:"mutate_event_key,omitempty"`
// Indicates the set of users to whom the event was delivered. If nil, then
// the client should not expect delivered status at any later point. If not
// nil (even if empty), this field indicates which users the event was
// delivered to.
DeliveredToUsers *[]id.UserID `json:"delivered_to_users,omitempty"`
}
type BeeperRetryMetadata struct {

View File

@@ -33,6 +33,8 @@ const (
MsgFile MessageType = "m.file"
MsgVerificationRequest MessageType = "m.key.verification.request"
MsgBeeperGallery MessageType = "com.beeper.gallery"
)
// Format specifies the format of the formatted_body in m.room.message events.
@@ -110,7 +112,10 @@ type MessageEventContent struct {
replyFallbackRemoved bool
MessageSendRetry *BeeperRetryMetadata `json:"com.beeper.message_send_retry,omitempty"`
MessageSendRetry *BeeperRetryMetadata `json:"com.beeper.message_send_retry,omitempty"`
BeeperGalleryImages []*MessageEventContent `json:"com.beeper.gallery.images,omitempty"`
BeeperGalleryCaption string `json:"com.beeper.gallery.caption,omitempty"`
BeeperGalleryCaptionHTML string `json:"com.beeper.gallery.caption_html,omitempty"`
}
func (content *MessageEventContent) GetRelatesTo() *RelatesTo {

View File

@@ -27,11 +27,10 @@ type PowerLevelsEventContent struct {
StateDefaultPtr *int `json:"state_default,omitempty"`
InvitePtr *int `json:"invite,omitempty"`
KickPtr *int `json:"kick,omitempty"`
BanPtr *int `json:"ban,omitempty"`
RedactPtr *int `json:"redact,omitempty"`
HistoricalPtr *int `json:"historical,omitempty"`
InvitePtr *int `json:"invite,omitempty"`
KickPtr *int `json:"kick,omitempty"`
BanPtr *int `json:"ban,omitempty"`
RedactPtr *int `json:"redact,omitempty"`
}
func copyPtr(ptr *int) *int {
@@ -66,11 +65,10 @@ func (pl *PowerLevelsEventContent) Clone() *PowerLevelsEventContent {
Notifications: pl.Notifications.Clone(),
InvitePtr: copyPtr(pl.InvitePtr),
KickPtr: copyPtr(pl.KickPtr),
BanPtr: copyPtr(pl.BanPtr),
RedactPtr: copyPtr(pl.RedactPtr),
HistoricalPtr: copyPtr(pl.HistoricalPtr),
InvitePtr: copyPtr(pl.InvitePtr),
KickPtr: copyPtr(pl.KickPtr),
BanPtr: copyPtr(pl.BanPtr),
RedactPtr: copyPtr(pl.RedactPtr),
}
}
@@ -122,13 +120,6 @@ func (pl *PowerLevelsEventContent) Redact() int {
return 50
}
func (pl *PowerLevelsEventContent) Historical() int {
if pl.HistoricalPtr != nil {
return *pl.HistoricalPtr
}
return 100
}
func (pl *PowerLevelsEventContent) StateDefault() int {
if pl.StateDefaultPtr != nil {
return *pl.StateDefaultPtr

View File

@@ -11,8 +11,6 @@ import (
"regexp"
"strings"
"golang.org/x/net/html"
"maunium.net/go/mautrix/id"
)
@@ -23,7 +21,7 @@ func TrimReplyFallbackHTML(html string) string {
}
func TrimReplyFallbackText(text string) string {
if !strings.HasPrefix(text, "> ") || !strings.Contains(text, "\n") {
if (!strings.HasPrefix(text, "> <") && !strings.HasPrefix(text, "> * <")) || !strings.Contains(text, "\n") {
return text
}
@@ -59,7 +57,7 @@ func (evt *Event) GenerateReplyFallbackHTML() string {
parsedContent.RemoveReplyFallback()
body := parsedContent.FormattedBody
if len(body) == 0 {
body = strings.ReplaceAll(html.EscapeString(parsedContent.Body), "\n", "<br/>")
body = TextToHTML(parsedContent.Body)
}
senderDisplayName := evt.Sender

View File

@@ -170,6 +170,7 @@ type ModPolicyContent struct {
Recommendation string `json:"recommendation"`
}
// Deprecated: MSC2716 has been abandoned
type InsertionMarkerContent struct {
InsertionID id.EventID `json:"org.matrix.msc2716.marker.insertion"`
Timestamp int64 `json:"com.beeper.timestamp,omitempty"`

View File

@@ -187,7 +187,9 @@ var (
StateHalfShotBridge = Type{"uk.half-shot.bridge", StateEventType}
StateSpaceChild = Type{"m.space.child", StateEventType}
StateSpaceParent = Type{"m.space.parent", StateEventType}
StateInsertionMarker = Type{"org.matrix.msc2716.marker", StateEventType}
// Deprecated: MSC2716 has been abandoned
StateInsertionMarker = Type{"org.matrix.msc2716.marker", StateEventType}
)
// Message events