mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:32:26 -05:00
[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
This commit is contained in:
parent
27bcc1fcbd
commit
fde0c6bc8c
5 changed files with 11 additions and 32 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue