From fde0c6bc8cce2d86269faf33739281a533566455 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Wed, 3 Jul 2024 15:53:54 -0700 Subject: [chore] Allow gtsmodel to depend on util (#3068) Convert one free function into a gtsmodel.Emoji method so that util does not depend on gtsmodel and can be used from it in the future --- internal/media/manager.go | 2 +- internal/media/refetch.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'internal/media') 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) -- cgit v1.3