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

Support auth for Lemmy 0.19 #4

Merged
merged 1 commit into from
Oct 10, 2023
Merged

Conversation

micahmo
Copy link
Member

@micahmo micahmo commented Oct 8, 2023

This PR introduces support for authenticating with Lemmy 0.19 instances. Note that I haven't tested anything beyond auth, although basic things seem to work fine.

Preface: For some reason, dart run build_runner build changed a ton of stuff (like adding Impl in a bunch of places to the generated code). I'm not sure if is because we updated build_runner in 2476ef6, and didn't regenerate, but I hope it's ok. In general, I think we can ignore .freezed.dart and .g.dart files anyway.

Here is a summary of changes and references to find amongst all the auto-generated code.

  1. Make the person admin field optional, so that we can handle its absence.
  2. Add auth token to headers.
    • This was done by adding a new abstract class with the auth property (code). All existing API methods with auth were updated to implement this class. Then in the invocation code, we can simply check whether the request contains auth, and pass that as a header (in addition to the existing query params) (code). I believe this approach has the following advantages.
      • We can support both methods of auth simultaneously (as recommended by Lemmy devs).
      • We can use the existing pattern of setting auth in the request object (and don't have to change any of the API models).

Related to thunder-app/thunder#762.

Demo

scrcpy_lFuPrUUco7.mp4

Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks again for taking the initial steps to add support for 0.19.x. We can do some more testing on this in the nightlies to find any issues that come up

@hjiangsu hjiangsu merged commit a95aa80 into thunder-app:master Oct 10, 2023
@micahmo micahmo deleted the 0.19-stuff branch October 10, 2023 22:47
hjiangsu pushed a commit that referenced this pull request Dec 27, 2024
In Lemmy v0.18.1, federation_worker_count is gone
gwbischof added a commit to gwbischof/lemmy_api_client that referenced this pull request Feb 1, 2025
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.

2 participants