Skip to content
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

Merged
merged 11 commits into from
Sep 12, 2022

Conversation

tsmethurst
Copy link
Contributor

@tsmethurst tsmethurst commented Sep 7, 2022

This PR:

  1. Adds GetRemoteEmoji function to the dereferencer, to put emojis in the db + in storage.
  2. Adds populateStatusEmojis for statuses from remote instances.
  3. Adds the UpdateStatus db function so that when we've pinned emojis to a status, we can put it in the cache.
  4. Adds config entries for media-emoji-local-max-size and media-emoji-remote-max-size

Together, these functions allow fetching + display of remote emojis in statuses.

Screenshot from 2022-09-07 10-42-10

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

TagID: i,
}).Exec(ctx); err != nil {
err = s.conn.errProc(err)
var alreadyExistsError *db.ErrAlreadyExists
Copy link
Member

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc Sep 9, 2022

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).

Copy link
Contributor Author

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)
Copy link
Member

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 :)

Copy link
Contributor Author

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

@tsmethurst
Copy link
Contributor Author

kim said, and i quote 'go nuts' so i am going nuts :)

@tsmethurst tsmethurst merged commit 268f252 into main Sep 12, 2022
@tsmethurst tsmethurst deleted the fetch_remote_emoji branch September 12, 2022 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] Emoji grabber
2 participants