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

URL encoding in query function and refactor #105

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

JacksonChen666
Copy link
Collaborator

@JacksonChen666 JacksonChen666 commented Mar 12, 2023

  1. query now accepts other things as part of str.format
  2. refactor all use of the query function in the project
  3. function documentation could be much better
  4. needs documentation on how to use query function

resolves #96


Things to look out for in this PR:

  • Nothing should an f-string or already have the information embedded in the URL part (AKA it should be this not this)
  • Basically given enough information to get back a string OR str.format doesn't break because it wasn't given enough things

@JacksonChen666 JacksonChen666 requested a review from JOJ0 March 12, 2023 17:02
@JacksonChen666 JacksonChen666 marked this pull request as ready for review March 15, 2023 13:36
Copy link
Owner

@JOJ0 JOJ0 left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this! LGTM except some additional documentation ideas within.

And one more thing about contributing docs but that let be my concern, you shouldn't be bothered with it! :-)

We need to update the Implementation Examples chapter, it is based on very old commits and just not the reality anymore. Now that f-strings are not allowed to use anymore it is even more wrong. I will take care of fixing that!

So as mentioned within the code, your part would be to add a tiny new chapter about the new string formatting concept. Thanks a lot!

synadm/api.py Show resolved Hide resolved
synadm/api.py Show resolved Hide resolved
@@ -297,7 +311,8 @@ def room_get_id(self, room_alias):
response as it might contain Synapse's error message.
"""
room_directory = self.query(
"get", f"client/r0/directory/room/{urllib.parse.quote(room_alias)}"
"get", "client/r0/directory/room/{room_alias}",
room_alias=room_alias
Copy link
Owner

Choose a reason for hiding this comment

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

I think it would be good if we state this new concept somewhere in the contributing docs. Telling the contributors about the new handling of args. I'm not quite sure where this should be.

Around here a new chapter around string formatting maybe? https://github.com/JOJ0/synadm/blob/master/CONTRIBUTING.md#command-design

Copy link
Owner

Choose a reason for hiding this comment

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

@JacksonChen666 if you want and think it's ready and tested enough we can merge this. I can take over the docs part. I would fix the links in this chapter https://github.com/JOJ0/synadm/blob/master/CONTRIBUTING.md#implementation-examples to point to a current version of these cli/user.py things and explain the passing as args and kwargs in a new PR that we can refine together then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not ready to merge (conflicts and outdated dev branch mess), but i'll hand off documentation to you then.

@JacksonChen666 JacksonChen666 linked an issue Mar 28, 2023 that may be closed by this pull request
@JacksonChen666
Copy link
Collaborator Author

JacksonChen666 commented Mar 28, 2023

oops included my extra stuff, rebasing...

1. query now accepts other things as part of str.format
2. refactor all use of the query function in the project
3. function documentation could be much better
4. needs documentation on how to use query function
@JacksonChen666 JacksonChen666 changed the base branch from dev to master March 28, 2023 18:31
@JacksonChen666
Copy link
Collaborator Author

should be good to merge

@JacksonChen666 JacksonChen666 merged commit 6874939 into master Mar 28, 2023
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.

Special internal room IDs breaks some commands
2 participants