passing user.id rather than the user directly

This commit is contained in:
Alan Roberts 2024-09-13 11:34:14 -04:00
parent 6b72b9cb64
commit 859edac084
2 changed files with 5 additions and 4 deletions

View file

@ -291,10 +291,10 @@ def admin_federation():
# capture the messages returned by do_subscibe # capture the messages returned by do_subscibe
# and show to user if instance is in debug mode # and show to user if instance is in debug mode
if current_app.debug: if current_app.debug:
message = do_subscribe(new_community.ap_id, user, main_user_name=False) message = do_subscribe(new_community.ap_id, user.id, main_user_name=False)
pre_load_messages.append(message) pre_load_messages.append(message)
else: else:
message_we_wont_do_anything_with = do_subscribe.delay(new_community.ap_id, user, main_user_name=False) message_we_wont_do_anything_with = do_subscribe.delay(new_community.ap_id, user.id, main_user_name=False)
if current_app.debug: if current_app.debug:
flash(_(f'Results: {pre_load_messages}')) flash(_(f'Results: {pre_load_messages}'))

View file

@ -390,14 +390,15 @@ def show_community_rss(actor):
@login_required @login_required
@validation_required @validation_required
def subscribe(actor): def subscribe(actor):
do_subscribe(actor, current_user) do_subscribe(actor, current_user.id)
# this is separated out from the route, so it can be used by the # this is separated out from the route, so it can be used by the
# admin.admin_federation.preload_form as well # admin.admin_federation.preload_form as well
@celery.task @celery.task
def do_subscribe(actor, user, main_user_name=True): def do_subscribe(actor, user_id, main_user_name=True):
remote = False remote = False
actor = actor.strip() actor = actor.strip()
user = User.query.get(user_id)
pre_load_message = {} pre_load_message = {}
if '@' in actor: if '@' in actor:
community = Community.query.filter_by(banned=False, ap_id=actor).first() community = Community.query.filter_by(banned=False, ap_id=actor).first()