From 31a8d81a420fe4a38d6fecf39a686f7cc1859a07 Mon Sep 17 00:00:00 2001 From: Meisam <39205857+MFTabriz@users.noreply.github.com> Date: Sat, 14 Aug 2021 21:48:04 +0200 Subject: [PATCH] Move emoji directory definition to config (#1317) * mv emojiDir to config * end comment with period --- config/constants.go | 2 ++ controllers/emoji.go | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config/constants.go b/config/constants.go index af68185a4..9d782241e 100644 --- a/config/constants.go +++ b/config/constants.go @@ -13,6 +13,8 @@ const ( FfmpegSuggestedVersion = "v4.1.5" // Requires the v // DataDirectory is the directory we save data to. DataDirectory = "data" + // EmojiDir is relative to the webroot. + EmojiDir = "/img/emoji" ) var ( diff --git a/controllers/emoji.go b/controllers/emoji.go index d0a42c203..ff4d14f1e 100644 --- a/controllers/emoji.go +++ b/controllers/emoji.go @@ -15,16 +15,12 @@ import ( log "github.com/sirupsen/logrus" ) -// Make this path configurable if somebody has a valid reason -// to need it to be. The config is getting a bit bloated. -const emojiDir = "/img/emoji" // Relative to webroot - var emojiCache = make([]models.CustomEmoji, 0) var emojiCacheTimestamp time.Time // getCustomEmojiList returns a list of custom emoji either from the cache or from the emoji directory. func getCustomEmojiList() []models.CustomEmoji { - fullPath := filepath.Join(config.WebRoot, emojiDir) + fullPath := filepath.Join(config.WebRoot, config.EmojiDir) emojiDirInfo, err := os.Stat(fullPath) if err != nil { log.Errorln(err) @@ -42,7 +38,7 @@ func getCustomEmojiList() []models.CustomEmoji { } for _, f := range files { name := strings.TrimSuffix(f.Name(), path.Ext(f.Name())) - emojiPath := filepath.Join(emojiDir, f.Name()) + emojiPath := filepath.Join(config.EmojiDir, f.Name()) singleEmoji := models.CustomEmoji{Name: name, Emoji: emojiPath} emojiCache = append(emojiCache, singleEmoji) }