diff --git a/app/admin/forms.py b/app/admin/forms.py index 62ce7c96..33fb5ed3 100644 --- a/app/admin/forms.py +++ b/app/admin/forms.py @@ -52,6 +52,7 @@ class FederationForm(FlaskForm): submit = SubmitField(_l('Save')) class PreLoadCommunitiesForm(FlaskForm): + communities_num = IntegerField(_l('Number of Communities to add')) pre_load_submit = SubmitField(_l('Add Communities')) class EditCommunityForm(FlaskForm): diff --git a/app/admin/routes.py b/app/admin/routes.py index c75ec433..fcb95c1d 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -201,8 +201,11 @@ def admin_federation(): # this is the pre-load communities button 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 - communities_to_add = 25 + # how many communities to add + if preload_form.communities_num.data: + communities_to_add = preload_form.communities_num.data + else: + communities_to_add = 25 # pull down the community.full.json resp = r.get('https://data.lemmyverse.net/data/community.full.json') @@ -280,16 +283,19 @@ def admin_federation(): for c in community_urls_to_join: # get the relevant url bits server, community = extract_domain_and_actor(c) + # message = {'server': server, 'community': community} # find the community new_community = search_for_community('!' + community + '@' + server) + # message = {'server': server, 'community': community, 'new_community': new_community} # subscribe to the community # since this is using the alt_user_name, capture the messages # returned by do_subscibe as well message = do_subscribe(new_community.ap_id, main_user_name=False) + pre_load_messages.append(message) - flash(_(f'top_20 == {top_20}')) - # flash(_(f'leng_before == {leng_before}, leng_middle == {leng_middle}, leng_after == {leng_after}')) + # flash(_(f'community_urls_to_join == {community_urls_to_join}')) # testing + flash(_(f'Results: {pre_load_messages}')) return redirect(url_for('admin.admin_federation')) # this is the main settings form