-
-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Fetch + display custom emoji in statuses from remote instances #807
Conversation
internal/db/bundb/status.go
Outdated
TagID: i, | ||
}).Exec(ctx); err != nil { | ||
err = s.conn.errProc(err) | ||
var alreadyExistsError *db.ErrAlreadyExists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrAlreadyExists as a type isn't actually being used anywhere other than here :'). I think a better alternative would be to update ErrAlreadyExists
to instead be var ErrAlreadyExists = errors.New("already exists")
, which can then be modified in the conn.errProc()
handler to be swapped out from whatever sqlite/postgres typically spit out. Then here instead can do if !errors.Is(err, db.ErrAlreadyExists)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this? b00c0ef
return nil, fmt.Errorf("GetRemoteEmoji: error creating transport: %s", err) | ||
} | ||
|
||
derefURI, err := url.Parse(remoteURL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to do a parse here. The transport already does URL parsing when creating the outgoing requests, so you should just be able to pass in remoteURL
to the dataFunc
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is a bit fiddly because the DereferenceMedia
function needs both a string iri and the parsed iri... If it's alright with you, I'll leave it for now in this PR, and we can sort it out in a separate PR, because changing the function signature in this PR means changing other parts of the code that aren't related to emojis
kim said, and i quote 'go nuts' so i am going nuts :) |
This PR:
GetRemoteEmoji
function to the dereferencer, to put emojis in the db + in storage.populateStatusEmojis
for statuses from remote instances.media-emoji-local-max-size
andmedia-emoji-remote-max-size
Together, these functions allow fetching + display of remote emojis in statuses.
In a future PR, we should extend this remote emoji fetching to also fetch emojis in content warnings, display names, and account notes/bios, but this is already a good start :)
Closes #295