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")
}
}
}
}