diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 310e6107..8a55f262 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -374,6 +374,7 @@ def shared_inbox(): redis_client.set(request_json['id'], 1, ex=90) # Save the activity ID into redis, to avoid duplicate activities that Lemmy sometimes sends activity_log.activity_id = request_json['id'] + g.site = Site.query.get(1) # g.site is not initialized by @app.before_request when request.path == '/inbox' if g.site.log_activitypub_json: activity_log.activity_json = json.dumps(request_json) activity_log.result = 'processing' diff --git a/pyfedi.py b/pyfedi.py index 410baaec..8efd05bb 100644 --- a/pyfedi.py +++ b/pyfedi.py @@ -53,7 +53,8 @@ with app.app_context(): def before_request(): session['nonce'] = gibberish() g.locale = str(get_locale()) - g.site = Site.query.get(1) + if request.path != '/inbox' and not request.path.startswith('/static/'): # do not load g.site on shared inbox, to increase chance of duplicate detection working properly + g.site = Site.query.get(1) if current_user.is_authenticated: current_user.last_seen = datetime.utcnow() current_user.email_unread_sent = False