mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-07 00:48:06 -06:00
[feature] Show + federate emojis in accounts (#837)
* Start adding account emoji * get emojis serialized + deserialized nicely * update tests * set / retrieve emojis on accounts * show account emojis in web view * fetch emojis from db based on ids * fix typo in test * lint * fix pg migration * update tests * update emoji checking logic * update comment * clarify comments + add some spacing * tidy up loops a lil (thanks kim)
This commit is contained in:
parent
15a67b7bef
commit
c4a08292ee
34 changed files with 934 additions and 127 deletions
|
|
@ -67,12 +67,13 @@ const (
|
|||
)
|
||||
|
||||
var registerTables = []interface{}{
|
||||
>smodel.AccountToEmoji{},
|
||||
>smodel.StatusToEmoji{},
|
||||
>smodel.StatusToTag{},
|
||||
}
|
||||
|
||||
// bunDBService satisfies the DB interface
|
||||
type bunDBService struct {
|
||||
// DBService satisfies the DB interface
|
||||
type DBService struct {
|
||||
db.Account
|
||||
db.Admin
|
||||
db.Basic
|
||||
|
|
@ -89,6 +90,12 @@ type bunDBService struct {
|
|||
conn *DBConn
|
||||
}
|
||||
|
||||
// GetConn returns the underlying bun connection.
|
||||
// Should only be used in testing + exceptional circumstance.
|
||||
func (dbService *DBService) GetConn() *DBConn {
|
||||
return dbService.conn
|
||||
}
|
||||
|
||||
func doMigration(ctx context.Context, db *bun.DB) error {
|
||||
migrator := migrate.NewMigrator(db, migrations.Migrations)
|
||||
|
||||
|
|
@ -177,7 +184,7 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
|
|||
// Prepare domain block cache
|
||||
blockCache := cache.NewDomainBlockCache()
|
||||
|
||||
ps := &bunDBService{
|
||||
ps := &DBService{
|
||||
Account: accounts,
|
||||
Admin: &adminDB{
|
||||
conn: conn,
|
||||
|
|
@ -399,7 +406,7 @@ func tweakConnectionValues(sqldb *sql.DB) {
|
|||
CONVERSION FUNCTIONS
|
||||
*/
|
||||
|
||||
func (ps *bunDBService) TagStringsToTags(ctx context.Context, tags []string, originAccountID string) ([]*gtsmodel.Tag, error) {
|
||||
func (dbService *DBService) TagStringsToTags(ctx context.Context, tags []string, originAccountID string) ([]*gtsmodel.Tag, error) {
|
||||
protocol := config.GetProtocol()
|
||||
host := config.GetHost()
|
||||
|
||||
|
|
@ -408,7 +415,7 @@ func (ps *bunDBService) TagStringsToTags(ctx context.Context, tags []string, ori
|
|||
tag := >smodel.Tag{}
|
||||
// we can use selectorinsert here to create the new tag if it doesn't exist already
|
||||
// inserted will be true if this is a new tag we just created
|
||||
if err := ps.conn.NewSelect().Model(tag).Where("LOWER(?) = LOWER(?)", bun.Ident("name"), t).Scan(ctx); err != nil {
|
||||
if err := dbService.conn.NewSelect().Model(tag).Where("LOWER(?) = LOWER(?)", bun.Ident("name"), t).Scan(ctx); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
// tag doesn't exist yet so populate it
|
||||
newID, err := id.NewRandomULID()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue