mirror of
https://github.com/owncast/owncast.git
synced 2024-11-25 22:31:09 +03:00
dc54dfe363
* Custom emoji editor: implement backend This reuses the logo upload code * Implement emoji edit admin interface Again reuse base64 logic from the logo upload * Allow toggling between uploaded and default emojis * Add route that always serves uploaded emojis This is needed for the admin emoji interface, as otherwise the emojis will 404 if custom emojis are disabled * Fix linter warnings * Remove custom/uploaded emoji logic * Reset timer after emoji deletion * Setup: copy built-in emojis to emoji directory
29 lines
709 B
Go
29 lines
709 B
Go
package controllers
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/owncast/owncast/config"
|
|
"github.com/owncast/owncast/core/data"
|
|
)
|
|
|
|
// GetCustomEmojiList returns a list of emoji via the API.
|
|
func GetCustomEmojiList(w http.ResponseWriter, r *http.Request) {
|
|
emojiList := data.GetEmojiList()
|
|
|
|
if err := json.NewEncoder(w).Encode(emojiList); err != nil {
|
|
InternalErrorHandler(w, err)
|
|
}
|
|
}
|
|
|
|
// GetCustomEmojiImage returns a single emoji image.
|
|
func GetCustomEmojiImage(w http.ResponseWriter, r *http.Request) {
|
|
path := strings.TrimPrefix(r.URL.Path, "/img/emoji/")
|
|
r.URL.Path = path
|
|
|
|
emojiFS := os.DirFS(config.CustomEmojiPath)
|
|
http.FileServer(http.FS(emojiFS)).ServeHTTP(w, r)
|
|
}
|