mirror of
https://github.com/pushbits/server.git
synced 2025-05-02 19:56:15 +02:00
multiple smaller fixes and improvements
This commit is contained in:
parent
a1558f6f63
commit
728c84676c
4 changed files with 9 additions and 21 deletions
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
var (
|
||||
tokenCharacters = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||
regularTokenLength = 64 // This length includes the prefix (one character).
|
||||
regularTokenLength = 63 // This length includes the prefix (one character).
|
||||
compatTokenLength = 15 // This length includes the prefix (one character).
|
||||
applicationTokenPrefix = "A"
|
||||
)
|
||||
|
|
|
@ -45,7 +45,7 @@ func (d *Dispatcher) DeregisterApplication(a *model.Application, u *model.User)
|
|||
|
||||
if _, err := d.mautrixClient.KickUser(mId.RoomID(a.MatrixID), &mautrix.ReqKickUser{
|
||||
Reason: "This application was deleted",
|
||||
UserID: mId.UserID(a.MatrixID),
|
||||
UserID: mId.UserID(u.MatrixID),
|
||||
}); err != nil {
|
||||
log.Print(err)
|
||||
return err
|
||||
|
|
|
@ -27,7 +27,7 @@ func Create(homeserver, username, password string, formatting configuration.Form
|
|||
Type: mautrix.AuthTypePassword,
|
||||
Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: username},
|
||||
Password: password,
|
||||
DeviceID: id.DeviceID("my-device"), // TODO make device ID configurable
|
||||
DeviceID: id.DeviceID("pushbits"),
|
||||
StoreCredentials: true,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -259,27 +259,15 @@ func (d *Dispatcher) respondToMessage(a *model.Application, body, formattedBody
|
|||
|
||||
// Extracts body and formatted body from a matrix message event
|
||||
func bodiesFromMessage(message *event.Event) (body, formattedBody string, err error) {
|
||||
if val, ok := message.Content.Raw["body"]; ok {
|
||||
body, ok := val.(string)
|
||||
|
||||
if !ok {
|
||||
return "", "", pberrors.ErrorMessageNotFound
|
||||
}
|
||||
|
||||
formattedBody = body
|
||||
|
||||
} else {
|
||||
msgContent := message.Content.AsMessage()
|
||||
if msgContent == nil {
|
||||
return "", "", pberrors.ErrorMessageNotFound
|
||||
}
|
||||
|
||||
if val, ok := message.Content.Raw["formatted_body"]; ok {
|
||||
body, ok := val.(string)
|
||||
if !ok {
|
||||
return "", "", pberrors.ErrorMessageNotFound
|
||||
}
|
||||
|
||||
formattedBody = body
|
||||
formattedBody = msgContent.FormattedBody
|
||||
if formattedBody == "" {
|
||||
formattedBody = msgContent.Body
|
||||
}
|
||||
|
||||
return body, formattedBody, nil
|
||||
return msgContent.Body, formattedBody, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue