Skip to content

Commit

Permalink
Merge pull request #104 from JOJ0/notice_streamline
Browse files Browse the repository at this point in the history
Streamline notice send --batch-size option
  • Loading branch information
JOJ0 authored Mar 10, 2023
2 parents b173306 + e522d92 commit 738b4e4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions synadm/cli/notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def notice():
help="""Interpret arguments as file paths instead of notice content and
read content from those files.""")
@click.option(
"--paginate", "-p", type=int, default=100, show_default=True,
metavar="PAGINATE", help="""The send command retrieves "pages" of users
from the homeserver, filters them and sends out the notices, before
retrieving the next page. PAGINATE sets how many users are in each of these
"pages". It is a performance setting and may be useful for servers with a
large amount of users.""")
"--batch-size", "--paginate", "-p", type=int, default=100,
show_default=True, metavar="SIZE",
help="""The send command retrieves "pages" of users from the homeserver,
filters them and sends out the notices, before retrieving the next page.
SIZE sets how many users are in each of these "pages". It is a performance
setting and may be useful for servers with a large amount of users.""")
@click.option(
"--regex", "-r", default=False, show_default=True, is_flag=True,
help="Interpret TO as regular expression.")
Expand All @@ -62,7 +62,7 @@ def notice():
@click.argument("plain", type=str, default=None)
@click.argument("formatted", type=str, default=None, required=False)
@click.pass_obj
def notice_send_cmd(helper, from_file, paginate, regex, preview_length,
def notice_send_cmd(helper, from_file, batch_size, regex, preview_length,
silent, to, plain, formatted):
"""Send server notices to users on the local homeserver.
Expand Down 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, paginate, True, False, "", "")
next_token, batch_size, True, False, "", "")
if "users" not in batch:
break
batch_mxids = [user['name'] for user in batch["users"]]
Expand Down Expand Up @@ -148,6 +148,6 @@ def confirm_prompt():
return

outputs = helper.api.notice_send(to, plain_content, formatted_content,
paginate, regex)
batch_size, regex)
if not silent:
helper.output(outputs)

0 comments on commit 738b4e4

Please sign in to comment.