summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/gtsmodel/emoji.go5
-rw-r--r--internal/media/manager.go2
-rw-r--r--internal/media/refetch.go7
-rw-r--r--internal/processing/admin/emoji.go4
-rw-r--r--internal/util/emoji.go25
5 files changed, 11 insertions, 32 deletions
diff --git a/internal/gtsmodel/emoji.go b/internal/gtsmodel/emoji.go
index c80e98ecb..7bf52586c 100644
--- a/internal/gtsmodel/emoji.go
+++ b/internal/gtsmodel/emoji.go
@@ -50,3 +50,8 @@ type Emoji struct {
func (e *Emoji) IsLocal() bool {
return e.Domain == ""
}
+
+// ShortcodeDomain returns the [shortcode]@[domain] for the given emoji.
+func (e *Emoji) ShortcodeDomain() string {
+ return e.Shortcode + "@" + e.Domain
+}
diff --git a/internal/media/manager.go b/internal/media/manager.go
index 90a2923b5..ea126e460 100644
--- a/internal/media/manager.go
+++ b/internal/media/manager.go
@@ -308,7 +308,7 @@ func (m *Manager) RefreshEmoji(
// paths before they get updated with new
// path ID. These are required for later
// deleting the old image files on refresh.
- shortcodeDomain := util.ShortcodeDomain(emoji)
+ shortcodeDomain := emoji.ShortcodeDomain()
oldStaticPath := emoji.ImageStaticPath
oldPath := emoji.ImagePath
diff --git a/internal/media/refetch.go b/internal/media/refetch.go
index c239655d2..d02f14872 100644
--- a/internal/media/refetch.go
+++ b/internal/media/refetch.go
@@ -27,7 +27,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
- "github.com/superseriousbusiness/gotosocial/internal/util"
)
type DereferenceMedia func(ctx context.Context, iri *url.URL) (io.ReadCloser, int64, error)
@@ -68,7 +67,7 @@ func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM
if refetch, err := m.emojiRequiresRefetch(ctx, emoji); err != nil {
// an error here indicates something is wrong with storage, so we should stop
- return 0, fmt.Errorf("error checking refetch requirement for emoji %s: %w", util.ShortcodeDomain(emoji), err)
+ return 0, fmt.Errorf("error checking refetch requirement for emoji %s: %w", emoji.ShortcodeDomain(), err)
} else if !refetch {
continue
}
@@ -77,7 +76,7 @@ func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM
}
// Update next maxShortcodeDomain from last emoji
- maxShortcodeDomain = util.ShortcodeDomain(emojis[len(emojis)-1])
+ maxShortcodeDomain = emojis[len(emojis)-1].ShortcodeDomain()
}
// bail early if we've got nothing to do
@@ -95,7 +94,7 @@ func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM
// this shouldn't happen--since we know we have the emoji--so return if it does
return 0, fmt.Errorf("error getting emoji %s: %w", emojiID, err)
}
- shortcodeDomain := util.ShortcodeDomain(emoji)
+ shortcodeDomain := emoji.ShortcodeDomain()
if emoji.ImageRemoteURL == "" {
log.Errorf(ctx, "remote emoji %s could not be refreshed because it has no ImageRemoteURL set", shortcodeDomain)
diff --git a/internal/processing/admin/emoji.go b/internal/processing/admin/emoji.go
index 4d1b464d3..c023fabd8 100644
--- a/internal/processing/admin/emoji.go
+++ b/internal/processing/admin/emoji.go
@@ -112,9 +112,9 @@ func (p *Processor) EmojisGet(
Items: items,
Path: "api/v1/admin/custom_emojis",
NextMaxIDKey: "max_shortcode_domain",
- NextMaxIDValue: util.ShortcodeDomain(emojis[count-1]),
+ NextMaxIDValue: emojis[count-1].ShortcodeDomain(),
PrevMinIDKey: "min_shortcode_domain",
- PrevMinIDValue: util.ShortcodeDomain(emojis[0]),
+ PrevMinIDValue: emojis[0].ShortcodeDomain(),
Limit: limit,
ExtraQueryParams: []string{
emojisGetFilterParams(
diff --git a/internal/util/emoji.go b/internal/util/emoji.go
deleted file mode 100644
index 7144da1a4..000000000
--- a/internal/util/emoji.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// GoToSocial
-// Copyright (C) GoToSocial Authors admin@gotosocial.org
-// SPDX-License-Identifier: AGPL-3.0-or-later
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-package util
-
-import "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
-
-// ShortcodeDomain returns the [shortcode]@[domain] for the given emoji.
-func ShortcodeDomain(emoji *gtsmodel.Emoji) string {
- return emoji.Shortcode + "@" + emoji.Domain
-}