-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add users support #6
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
Draft
ooliver1
wants to merge
27
commits into
next
Choose a base branch
from
ooliver1/feat/users
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EnokiUN
requested changes
Jun 17, 2023
Member
EnokiUN
left a comment
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.
a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds users support, added in https://github.com/eludris/eludris/tree/enoki/users. This has not been merged into
nextyet, so neither will this PR.Details in order of diff:
Configuration is stored in
~/.config/pilfer/Pilfer.toml(user token), like the Eludris CLI in eludris/eludris#79. This is too, configurable viaPILFER_CONF.Documentation in the README has been added for existing and new keybinds.
Authentication is done once
HELLOhas been received.heartbeat_intervalis actually in milliseconds, not seconds, which was an issue since pilfer would disconnect and reconnect.A list has been added to the right of the messages box, which is togglable using
Ctrl + U. This is a list of currently online users (notOFFLINE) - soONLINE,IDLE, andBUSY. It is stored as a hashmap ofid: Userfor now. This is so it can be updated easily and quickly when receiving aPRESENCE_UPDATE. It is not necessary to store this in a simplified structure containing display name and status, since theUserstruct is already small. If a user is not known, it is fetched from the API and added to the hashmap.Instances of
msg.message.contenthave been altered to usemsg.message.contentas in todel, this is a flattened common struct. ABoxis used aroundPilfer::Eludris()as eludris message structs are not as small as they used to be, and this is passed around a lot.The instance version is checked against the
pilferpackage version. Right now, it must be0.4.0-alpha1or greater to not fail. If the instance is lower, an error is printed, suggesting usage ofINSTANCE_URLfor the next instance or some other instance. If the instance is higher, an error is thrown, suggesting updatingpilfer.run_appis used underspawn_blockingas it should be ran in an executor forterminal.draw(|f| ui(f, &app))to use locks in a blocking manner. This means thatterminalis then passed back to the caller, to avoidArc+Mutexusage.run_appcontains a closure with the inner logic, as the terminal also needs to be returned. This avoids having to return(terminal, err)on error, andterminalon success. Aboolis used for if the loop should continue, or not (Ctrl + C).MessageResponsehas been changed toResponse<T>to be more universal, as it can then be more universally used for API errors.The user list is rendered inside the same chunk as
messages, so it can then be optionally split horizontally. The users list is locked at 20 characters to be big enough to read, but small enough to not be intrusive.Ctrl + Ucan still get rid of it in stupidly small terminal windows.Users are authenticated using an initial
Y/nprompt for logging in or registering. Username/email is then prompted in both cases, and password viarpasswordfor cross-platform hidden input. In the signup case, ifInstanceInfo.email_addressexists, the user is reminded to usepilfer --verifywith their email verification code.platformis the OS's human lowercase name, such aslinux,windows,macos, ..., andclientispilfer.This is a Code Change