add !pm banlist:totals, fix notices on reactions

This commit is contained in:
Aine
2023-09-28 08:30:37 +03:00
parent 7fbb279830
commit da41bd31fb
10 changed files with 64 additions and 10 deletions

View File

@@ -21,6 +21,6 @@ vuln:
# run unit tests
test:
@go test ${BUILDFLAGS} -coverprofile=cover.out ./...
@go test -coverprofile=cover.out ./...
@go tool cover -func=cover.out
-@rm -f cover.out

View File

@@ -21,15 +21,24 @@ func (l *Linkpearl) Send(roomID id.RoomID, content interface{}) (id.EventID, err
// SendNotice to a room with optional relations, markdown supported
func (l *Linkpearl) SendNotice(roomID id.RoomID, message string, relates ...*event.RelatesTo) {
var withRelatesTo bool
content := format.RenderMarkdown(message, true, true)
content.MsgType = event.MsgNotice
if len(relates) > 0 {
withRelatesTo = true
content.RelatesTo = relates[0]
}
_, err := l.Send(roomID, &content)
if err != nil {
l.log.Error().Err(UnwrapError(err)).Str("roomID", roomID.String()).Msg("cannot send a notice int the room")
l.log.Error().Err(UnwrapError(err)).Str("roomID", roomID.String()).Str("retries", "1/2").Msg("cannot send a notice into the room")
if withRelatesTo {
content.RelatesTo = nil
_, err = l.Send(roomID, &content)
if err != nil {
l.log.Error().Err(UnwrapError(err)).Str("roomID", roomID.String()).Str("retries", "2/2").Msg("cannot send a notice into the room even without relations")
}
}
}
}

2
vendor/modules.txt vendored
View File

@@ -144,7 +144,7 @@ gitlab.com/etke.cc/go/trysmtp
# gitlab.com/etke.cc/go/validator v1.0.6
## explicit; go 1.18
gitlab.com/etke.cc/go/validator
# gitlab.com/etke.cc/linkpearl v0.0.0-20230927084751-e9a37b134a8a
# gitlab.com/etke.cc/linkpearl v0.0.0-20230928051620-7f1b7d54e9a8
## explicit; go 1.18
gitlab.com/etke.cc/linkpearl
# go.mau.fi/util v0.1.0