mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Syncing twitter photos on user cleanup (1% of the time).
This commit is contained in:
parent
5e59d740e5
commit
5afdde8661
2 changed files with 13 additions and 1 deletions
|
@ -1,8 +1,10 @@
|
|||
import datetime
|
||||
import random
|
||||
from celery.task import Task
|
||||
from apps.profile.models import Profile, RNewUserQueue
|
||||
from utils import log as logging
|
||||
from apps.reader.models import UserSubscription
|
||||
from apps.social.models import MSocialServices
|
||||
|
||||
class EmailNewUser(Task):
|
||||
|
||||
|
@ -37,14 +39,21 @@ class PremiumExpire(Task):
|
|||
profile.send_premium_expire_email()
|
||||
profile.deactivate_premium()
|
||||
|
||||
|
||||
class ActivateNextNewUser(Task):
|
||||
name = 'activate-next-new-user'
|
||||
|
||||
def run(self):
|
||||
RNewUserQueue.activate_next()
|
||||
|
||||
|
||||
class CleanupUser(Task):
|
||||
name = 'cleanup-user'
|
||||
|
||||
def run(self, user_id):
|
||||
UserSubscription.trim_user_read_stories(user_id)
|
||||
|
||||
if random.random() < 0.01:
|
||||
ss = MSocialServices.objects.get(user_id=user_id)
|
||||
ss.sync_twitter_photo()
|
||||
|
||||
|
|
|
@ -2553,11 +2553,14 @@ class MSocialServices(mongo.Document):
|
|||
if profile.photo_service != "twitter":
|
||||
return
|
||||
|
||||
user = User.objects.get(pk=self.user_id)
|
||||
logging.user(user, "~FCSyncing Twitter profile photo...")
|
||||
|
||||
try:
|
||||
api = self.twitter_api()
|
||||
me = api.me()
|
||||
except tweepy.TweepError, e:
|
||||
print " ***> Exception (%s): setting to blank profile photo" % e
|
||||
logging.user(user, "~FRException (%s): ~FCsetting to blank profile photo" % e)
|
||||
self.twitter_picture_url = None
|
||||
self.set_photo("nothing")
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue