Skip to content

Commit

Permalink
Merge pull request #128 from JOJ0/fix-missing-parameters
Browse files Browse the repository at this point in the history
Fix existing calls to user_list API breaking
  • Loading branch information
JacksonChen666 authored Sep 14, 2023
2 parents 0d2a1f7 + e540438 commit 1e10ab8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions synadm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def __init__(self, log, user, token, base_url, admin_path, timeout, debug,
self.user = user

def user_list(self, _from, _limit, _guests, _deactivated,
_name, _user_id, _admin):
_name, _user_id, _admin=None):
"""List and search users
Args:
Expand Down Expand Up @@ -446,7 +446,7 @@ def user_list(self, _from, _limit, _guests, _deactivated,
return self.query("get", "v2/users", params=params)

def user_list_paginate(self, _limit, _guests, _deactivated,
_name, _user_id, _from="0"):
_name, _user_id, _from="0", admin=None):
# documentation is mostly duplicated from user_list...
"""Yields API responses for all of the pagination.
Expand All @@ -468,7 +468,7 @@ def user_list_paginate(self, _limit, _guests, _deactivated,
"""
while _from is not None:
response = self.user_list(_from, _limit, _guests, _deactivated,
_name, _user_id)
_name, _user_id, admin)
yield response
_from = response.get("next_token", None)

Expand Down Expand Up @@ -1345,7 +1345,7 @@ def notice_send(self, receivers, content_plain, content_html, paginate,
# A regular expression was supplied to match receivers.
if regex:
outputs = []
response = self.user_list(0, paginate, True, False, "", "")
response = self.user_list(0, paginate, True, False, "", "", None)
if "users" not in response:
return
while True:
Expand All @@ -1361,7 +1361,7 @@ def notice_send(self, receivers, content_plain, content_html, paginate,
if "next_token" not in response:
return outputs
response = self.user_list(response["next_token"],
100, True, False, "", "")
100, True, False, "", "", None)
# Only a single user ID was supplied as receiver
else:
data["user_id"] = receivers
Expand Down
5 changes: 3 additions & 2 deletions synadm/cli/notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def confirm_prompt():
# Outer loop: If fetching >1 pages of users is required
while ctr < preview_length:
batch = helper.api.user_list(
next_token, batch_size, True, False, "", "")
next_token, batch_size, True, False, "", "", None)
if "users" not in batch:
break
batch_mxids = [user['name'] for user in batch["users"]]
Expand Down Expand Up @@ -135,7 +135,8 @@ def confirm_prompt():
formatted_content = formatted if formatted else plain_content

if regex:
if "users" not in helper.api.user_list(0, 100, True, False, "", ""):
if "users" not in helper.api.user_list(0, 100, True, False, "", "",
None):
return
if not confirm_prompt():
return
Expand Down

0 comments on commit 1e10ab8

Please sign in to comment.