2012-06-27 23:58:10 -07:00
|
|
|
from celery.task import Task
|
2012-07-10 15:24:54 -07:00
|
|
|
from apps.social.models import MSharedStory, MSocialProfile, MSocialServices
|
2012-07-31 11:41:30 -07:00
|
|
|
from utils import log as logging
|
2012-06-27 23:58:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
class PostToService(Task):
|
|
|
|
|
|
|
|
def run(self, shared_story_id, service):
|
|
|
|
try:
|
|
|
|
shared_story = MSharedStory.objects.get(id=shared_story_id)
|
|
|
|
shared_story.post_to_service(service)
|
|
|
|
except MSharedStory.DoesNotExist:
|
2012-07-31 11:41:30 -07:00
|
|
|
logging.debug(" ---> Shared story not found (%s). Can't post to: %s" % (shared_story_id, service))
|
2012-06-27 23:58:10 -07:00
|
|
|
|
|
|
|
class EmailNewFollower(Task):
|
|
|
|
|
|
|
|
def run(self, follower_user_id, followee_user_id):
|
2012-07-25 23:57:10 -07:00
|
|
|
user_profile = MSocialProfile.get_user(followee_user_id)
|
2012-07-05 18:29:38 -07:00
|
|
|
user_profile.send_email_for_new_follower(follower_user_id)
|
|
|
|
|
|
|
|
class EmailCommentReplies(Task):
|
|
|
|
|
2012-07-27 18:58:35 -07:00
|
|
|
def run(self, shared_story_id, reply_id):
|
2012-07-05 18:29:38 -07:00
|
|
|
shared_story = MSharedStory.objects.get(id=shared_story_id)
|
2012-07-27 18:58:35 -07:00
|
|
|
shared_story.send_emails_for_new_reply(reply_id)
|
2012-07-05 18:29:38 -07:00
|
|
|
|
2012-07-05 19:50:02 -07:00
|
|
|
class EmailStoryReshares(Task):
|
|
|
|
|
|
|
|
def run(self, shared_story_id):
|
|
|
|
shared_story = MSharedStory.objects.get(id=shared_story_id)
|
|
|
|
shared_story.send_email_for_reshare()
|
|
|
|
|
2012-07-10 15:24:54 -07:00
|
|
|
class SyncTwitterFriends(Task):
|
|
|
|
|
|
|
|
def run(self, user_id):
|
|
|
|
social_services = MSocialServices.objects.get(user_id=user_id)
|
|
|
|
social_services.sync_twitter_friends()
|
|
|
|
|
|
|
|
class SyncFacebookFriends(Task):
|
|
|
|
|
|
|
|
def run(self, user_id):
|
|
|
|
social_services = MSocialServices.objects.get(user_id=user_id)
|
|
|
|
social_services.sync_facebook_friends()
|
|
|
|
|
2012-07-31 11:41:30 -07:00
|
|
|
class SharePopularStories(Task):
|
|
|
|
name = 'share-popular-stories'
|
|
|
|
|
|
|
|
def run(self, **kwargs):
|
|
|
|
logging.debug(" ---> Sharing popular stories...")
|
2012-09-10 13:08:12 -07:00
|
|
|
shared = MSharedStory.share_popular_stories(interactive=False)
|
|
|
|
if not shared:
|
|
|
|
shared = MSharedStory.share_popular_stories(interactive=False, days=2)
|
|
|
|
|
2012-07-31 11:41:30 -07:00
|
|
|
|