Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Clean up the URL generation code
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Dec 20, 2021
1 parent f11fc08 commit 168f31e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/rest/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
overload,
)
from unittest.mock import patch
from urllib.parse import urlencode

import attr
from typing_extensions import Literal
Expand Down Expand Up @@ -235,15 +236,16 @@ def change_membership(
temp_id = self.auth_user_id
self.auth_user_id = src

path = "/_matrix/client/r0/rooms/%s/state/m.room.member/%s" % (room, targ)
next_arg_char = "?"
path = f"/_matrix/client/r0/rooms/{room}/state/m.room.member/{targ}"
url_params: Dict[str, str] = {}

if tok:
path += "?access_token=%s" % tok
next_arg_char = "&"
url_params["access_token"] = tok

if appservice_user_id:
path += f"{next_arg_char}user_id={appservice_user_id}"
url_params["user_id"] = appservice_user_id

path += "?" + urlencode(url_params)

data = {"membership": membership}
data.update(extra_data or {})
Expand Down

0 comments on commit 168f31e

Please sign in to comment.