Started working on emoji
|
@ -36,6 +36,10 @@ const (
|
|||
mediaTypeKey = "media_type"
|
||||
mediaSizeKey = "media_size"
|
||||
fileNameKey = "file_name"
|
||||
shortcodeKey = "shortcode"
|
||||
|
||||
emojisPath = "emojis"
|
||||
filesPath = "files"
|
||||
)
|
||||
|
||||
// fileServer implements the RESTAPIModule interface.
|
||||
|
@ -62,6 +66,7 @@ func New(config *config.Config, db db.DB, storage storage.Storage, log *logrus.L
|
|||
// Route satisfies the RESTAPIModule interface
|
||||
func (m *fileServer) Route(s router.Router) error {
|
||||
s.AttachHandler(http.MethodGet, fmt.Sprintf("%s/:%s/:%s/:%s/:%s", m.storageBase, accountIDKey, mediaTypeKey, mediaSizeKey, fileNameKey), m.ServeFile)
|
||||
s.AttachHandler(http.MethodGet, fmt.Sprintf("%s/:%s/:%s/:%s/:%s", m.storageBase, accountIDKey, mediaTypeKey, mediaSizeKey, fileNameKey), m.serveEmoji)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package fileserver
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (m *fileServer) serveEmoji(c *gin.Context) {
|
||||
|
||||
}
|
|
@ -111,6 +111,10 @@ type DB interface {
|
|||
HANDY SHORTCUTS
|
||||
*/
|
||||
|
||||
// CreateInstanceAccount creates an account in the database with the same username as the instance host value.
|
||||
// Ie., if the instance is hosted at 'example.org' the instance user will have a username of 'example.org'.
|
||||
CreateInstanceAccount() error
|
||||
|
||||
// GetAccountByUserID is a shortcut for the common action of fetching an account corresponding to a user ID.
|
||||
// The given account pointer will be set to the result of the query, whatever it is.
|
||||
// In case of no entries, a 'no entries' error will be returned
|
||||
|
|
|
@ -21,17 +21,41 @@ package gtsmodel
|
|||
import "time"
|
||||
|
||||
type Emoji struct {
|
||||
ID string `pg:"type:uuid,default:gen_random_uuid(),pk,notnull"`
|
||||
Shortcode string `pg:"notnull"`
|
||||
CreatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
|
||||
UpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
|
||||
ImageFileName string
|
||||
ImageContentType string
|
||||
ImageFileSize string
|
||||
ImageUpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
|
||||
Disabled bool
|
||||
URI string
|
||||
ImageRemoteURL string
|
||||
VisibleInPicker bool
|
||||
CategoryID string
|
||||
// database ID of this emoji
|
||||
ID string `pg:"type:uuid,default:gen_random_uuid(),pk,notnull"`
|
||||
// String shortcode for this emoji -- the part that's between colons. This should be lowercase a-z_
|
||||
// eg., 'blob_hug' 'purple_heart' Must be unique with domain.
|
||||
Shortcode string `pg:"notnull,unique:shortcodedomain"`
|
||||
// Origin domain of this emoji, eg 'example.org', 'queer.party'. Null for local emojis.
|
||||
Domain string `pg:",unique:shortcodedomain"`
|
||||
// When was this emoji created. Must be unique with shortcode.
|
||||
CreatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
|
||||
// When was this emoji updated
|
||||
UpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
|
||||
// Where can this emoji be retrieved remotely? Null for local emojis.
|
||||
// For remote emojis, it'll be something like:
|
||||
// https://hackers.town/system/custom_emojis/images/000/049/842/original/1b74481204feabfd.png
|
||||
ImageRemoteURL string
|
||||
// Where can this emoji be retrieved from the local server? Null for remote emojis.
|
||||
// Assuming our server is hosted at 'example.org', this will be something like:
|
||||
// 'https://example.org/fileserver/emojis/bfa6c9c5-6c25-4ea4-98b4-d78b8126fb52.png'
|
||||
ImageURL string
|
||||
// Path of the emoji image in the server storage system.
|
||||
// Will be something like '/gotosocial/storage/emojis/bfa6c9c5-6c25-4ea4-98b4-d78b8126fb52.png'
|
||||
ImagePath string `pg:",notnull"`
|
||||
// MIME content type of the emoji image
|
||||
// Probably "image/png"
|
||||
ImageContentType string `pg:",notnull"`
|
||||
// Size of the emoji image file in bytes, for serving purposes.
|
||||
ImageFileSize int `pg:",notnull"`
|
||||
// When was the emoji image last updated?
|
||||
ImageUpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
|
||||
// Has a moderation action disabled this emoji from being shown?
|
||||
Disabled bool `pg:",notnull,default:false"`
|
||||
// ActivityStreams uri of this emoji. Something like 'https://example.org/emojis/1234'
|
||||
URI string `pg:",notnull,unique"`
|
||||
// Is this emoji visible in the admin emoji picker?
|
||||
VisibleInPicker bool `pg:",notnull,default:true"`
|
||||
// In which emoji category is this emoji visible?
|
||||
CategoryID string
|
||||
}
|
||||
|
|
|
@ -312,6 +312,23 @@ func (ps *postgresService) DeleteWhere(key string, value interface{}, i interfac
|
|||
HANDY SHORTCUTS
|
||||
*/
|
||||
|
||||
func (ps *postgresService) CreateInstanceAccount() error {
|
||||
username := ps.config.Host
|
||||
instanceAccount := >smodel.Account{
|
||||
Username: username,
|
||||
}
|
||||
inserted, err := ps.conn.Model(instanceAccount).Where("username = ?", username).SelectOrInsert();
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if inserted {
|
||||
ps.log.Infof("created instance account %s with id %s",username, instanceAccount.ID)
|
||||
} else {
|
||||
ps.log.Infof("instance account %s already exists with id %s", username, instanceAccount.ID)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps *postgresService) GetAccountByUserID(userID string, account *gtsmodel.Account) error {
|
||||
user := >smodel.User{
|
||||
ID: userID,
|
||||
|
|
|
@ -38,6 +38,7 @@ const (
|
|||
MediaAttachment = "attachment"
|
||||
MediaHeader = "header"
|
||||
MediaAvatar = "avatar"
|
||||
MediaEmoji = "emoji"
|
||||
)
|
||||
|
||||
// MediaHandler provides an interface for parsing, storing, and retrieving media objects like photos, videos, and gifs.
|
||||
|
|
|
@ -58,6 +58,10 @@ func NewTestDB() db.DB {
|
|||
|
||||
// StandardDBSetup populates a given db with all the necessary tables/models for perfoming tests.
|
||||
func StandardDBSetup(db db.DB) {
|
||||
if err := db.CreateInstanceAccount(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, m := range testModels {
|
||||
if err := db.CreateTable(m); err != nil {
|
||||
panic(err)
|
||||
|
|
Before Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 293 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 263 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.0 MiB |