mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
only refresh community and user profiles of online instances
This commit is contained in:
parent
d0cc79f8ad
commit
41cadc1f72
2 changed files with 3 additions and 2 deletions
|
@ -478,7 +478,7 @@ def refresh_user_profile(user_id):
|
|||
@celery.task
|
||||
def refresh_user_profile_task(user_id):
|
||||
user = User.query.get(user_id)
|
||||
if user:
|
||||
if user and user.instance.online():
|
||||
try:
|
||||
actor_data = get_request(user.ap_public_url, headers={'Accept': 'application/activity+json'})
|
||||
except requests.exceptions.ReadTimeout:
|
||||
|
@ -557,7 +557,7 @@ def refresh_community_profile(community_id):
|
|||
@celery.task
|
||||
def refresh_community_profile_task(community_id):
|
||||
community = Community.query.get(community_id)
|
||||
if community and not community.is_local():
|
||||
if community and community.instance.online() and not community.is_local():
|
||||
try:
|
||||
actor_data = get_request(community.ap_public_url, headers={'Accept': 'application/activity+json'})
|
||||
except requests.exceptions.ReadTimeout:
|
||||
|
|
|
@ -408,6 +408,7 @@ class Community(db.Model):
|
|||
icon = db.relationship('File', foreign_keys=[icon_id], single_parent=True, backref='community', cascade="all, delete-orphan")
|
||||
image = db.relationship('File', foreign_keys=[image_id], single_parent=True, cascade="all, delete-orphan")
|
||||
languages = db.relationship('Language', lazy='dynamic', secondary=community_language, backref=db.backref('communities', lazy='dynamic'))
|
||||
instance = db.relationship('Instance', lazy='dynamic', foreign_keys=[instance_id])
|
||||
|
||||
def language_ids(self):
|
||||
return [language.id for language in self.languages.all()]
|
||||
|
|
Loading…
Reference in a new issue