Add support for custom emoji in reactions.

This seems to be working correctly, but element-desktop isn't rendering them,
not sure if that's expected or not.

Closes #4
This commit is contained in:
Gary Kramlich
2022-02-19 10:14:43 -06:00
parent 1c2dc8e9da
commit a51b1074ba
7 changed files with 232 additions and 16 deletions

44
database/emojiquery.go Normal file
View File

@@ -0,0 +1,44 @@
package database
import (
log "maunium.net/go/maulogger/v2"
"maunium.net/go/mautrix/id"
)
type EmojiQuery struct {
db *Database
log log.Logger
}
const (
emojiSelect = "SELECT discord_id, discord_name, matrix_url FROM emoji"
)
func (eq *EmojiQuery) New() *Emoji {
return &Emoji{
db: eq.db,
log: eq.log,
}
}
func (eq *EmojiQuery) GetByDiscordID(discordID string) *Emoji {
query := emojiSelect + " WHERE discord_id=$1"
return eq.get(query, discordID)
}
func (eq *EmojiQuery) GetByMatrixURL(matrixURL id.ContentURI) *Emoji {
query := emojiSelect + " WHERE matrix_url=$1"
return eq.get(query, matrixURL.String())
}
func (eq *EmojiQuery) get(query string, args ...interface{}) *Emoji {
row := eq.db.QueryRow(query, args...)
if row == nil {
return nil
}
return eq.New().Scan(row)
}