mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
work to make the num of communities user configurable
This commit is contained in:
parent
f00a9b2722
commit
cf2400e5d5
2 changed files with 11 additions and 4 deletions
|
@ -52,6 +52,7 @@ class FederationForm(FlaskForm):
|
||||||
submit = SubmitField(_l('Save'))
|
submit = SubmitField(_l('Save'))
|
||||||
|
|
||||||
class PreLoadCommunitiesForm(FlaskForm):
|
class PreLoadCommunitiesForm(FlaskForm):
|
||||||
|
communities_num = IntegerField(_l('Number of Communities to add'))
|
||||||
pre_load_submit = SubmitField(_l('Add Communities'))
|
pre_load_submit = SubmitField(_l('Add Communities'))
|
||||||
|
|
||||||
class EditCommunityForm(FlaskForm):
|
class EditCommunityForm(FlaskForm):
|
||||||
|
|
|
@ -201,7 +201,10 @@ def admin_federation():
|
||||||
|
|
||||||
# this is the pre-load communities button
|
# this is the pre-load communities button
|
||||||
if preload_form.pre_load_submit.data and preload_form.validate():
|
if preload_form.pre_load_submit.data and preload_form.validate():
|
||||||
# var - how many communities to add, hard-coded to 20 for now, can be made editable later
|
# how many communities to add
|
||||||
|
if preload_form.communities_num.data:
|
||||||
|
communities_to_add = preload_form.communities_num.data
|
||||||
|
else:
|
||||||
communities_to_add = 25
|
communities_to_add = 25
|
||||||
|
|
||||||
# pull down the community.full.json
|
# pull down the community.full.json
|
||||||
|
@ -280,16 +283,19 @@ def admin_federation():
|
||||||
for c in community_urls_to_join:
|
for c in community_urls_to_join:
|
||||||
# get the relevant url bits
|
# get the relevant url bits
|
||||||
server, community = extract_domain_and_actor(c)
|
server, community = extract_domain_and_actor(c)
|
||||||
|
# message = {'server': server, 'community': community}
|
||||||
# find the community
|
# find the community
|
||||||
new_community = search_for_community('!' + community + '@' + server)
|
new_community = search_for_community('!' + community + '@' + server)
|
||||||
|
# message = {'server': server, 'community': community, 'new_community': new_community}
|
||||||
# subscribe to the community
|
# subscribe to the community
|
||||||
# since this is using the alt_user_name, capture the messages
|
# since this is using the alt_user_name, capture the messages
|
||||||
# returned by do_subscibe as well
|
# returned by do_subscibe as well
|
||||||
message = do_subscribe(new_community.ap_id, main_user_name=False)
|
message = do_subscribe(new_community.ap_id, main_user_name=False)
|
||||||
|
pre_load_messages.append(message)
|
||||||
|
|
||||||
|
|
||||||
flash(_(f'top_20 == {top_20}'))
|
# flash(_(f'community_urls_to_join == {community_urls_to_join}')) # testing
|
||||||
# flash(_(f'leng_before == {leng_before}, leng_middle == {leng_middle}, leng_after == {leng_after}'))
|
flash(_(f'Results: {pre_load_messages}'))
|
||||||
return redirect(url_for('admin.admin_federation'))
|
return redirect(url_for('admin.admin_federation'))
|
||||||
|
|
||||||
# this is the main settings form
|
# this is the main settings form
|
||||||
|
|
Loading…
Add table
Reference in a new issue