mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00

* master: Warning on missing maintenance. Further pushing out feed updates. Using @dcramer's excellent getsentry.com for all exceptions. Turning off exception emails. Further pushing down feed fetches to handle load until db is scaled out. Scrolling code blocks. New task servers. Turning down feed fetches. If requests.raw won't work, sut fudge it with a StringIO for now. Further turning down feed fetches until mongo is ready to replicate. Fixing Facebook image calculation. Fixing facebook posting. Moving shared story unread recalc to background task. Will greatly speed up sharing. Ramping down feed fetching until they can be handled. Only show time breakdown when > 1 sec. Fixed API docs for /reader/river_stories make fabfile.py use requirements.txt Make sure to send the proper content-type with social feeds Restore default whitespace to pre/code blocks Phase 2: switching to using story_hash index instead of compound unique story_feed_id/story_guid index. document keyboard shortcut to add site/folder Conflicts: apps/social/views.py
83 lines
3.1 KiB
Python
83 lines
3.1 KiB
Python
from bson.objectid import ObjectId
|
|
from celery.task import Task
|
|
from apps.social.models import MSharedStory, MSocialProfile, MSocialServices, MSocialSubscription
|
|
from django.contrib.auth.models import User
|
|
from utils import log as logging
|
|
|
|
|
|
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:
|
|
logging.debug(" ---> Shared story not found (%s). Can't post to: %s" % (shared_story_id, service))
|
|
|
|
class EmailNewFollower(Task):
|
|
|
|
def run(self, follower_user_id, followee_user_id):
|
|
user_profile = MSocialProfile.get_user(followee_user_id)
|
|
user_profile.send_email_for_new_follower(follower_user_id)
|
|
|
|
class EmailFollowRequest(Task):
|
|
|
|
def run(self, follower_user_id, followee_user_id):
|
|
user_profile = MSocialProfile.get_user(followee_user_id)
|
|
user_profile.send_email_for_follow_request(follower_user_id)
|
|
|
|
class EmailCommentReplies(Task):
|
|
|
|
def run(self, shared_story_id, reply_id):
|
|
shared_story = MSharedStory.objects.get(id=shared_story_id)
|
|
shared_story.send_emails_for_new_reply(reply_id)
|
|
|
|
class EmailStoryReshares(Task):
|
|
|
|
def run(self, shared_story_id):
|
|
shared_story = MSharedStory.objects.get(id=shared_story_id)
|
|
shared_story.send_email_for_reshare()
|
|
|
|
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()
|
|
|
|
class SyncAppdotnetFriends(Task):
|
|
|
|
def run(self, user_id):
|
|
social_services = MSocialServices.objects.get(user_id=user_id)
|
|
social_services.sync_appdotnet_friends()
|
|
|
|
class SharePopularStories(Task):
|
|
name = 'share-popular-stories'
|
|
|
|
def run(self, **kwargs):
|
|
logging.debug(" ---> Sharing popular stories...")
|
|
shared = MSharedStory.share_popular_stories(interactive=False)
|
|
if not shared:
|
|
shared = MSharedStory.share_popular_stories(interactive=False, days=2)
|
|
|
|
|
|
class UpdateRecalcForSubscription(Task):
|
|
|
|
def run(self, subscription_user_id, shared_story_id):
|
|
user = User.objects.get(pk=subscription_user_id)
|
|
socialsubs = MSocialSubscription.objects.filter(subscription_user_id=subscription_user_id)
|
|
logging.debug(" ---> ~FM~SNFlipping unread recalc for ~SB%s~SN subscriptions to ~SB%s's blurblog~SN" % (
|
|
socialsubs.count(),
|
|
user.username
|
|
))
|
|
for socialsub in socialsubs:
|
|
socialsub.needs_unread_recalc = True
|
|
socialsub.save()
|
|
|
|
shared_story = MSharedStory.objects.get(id=ObjectId(shared_story_id))
|
|
shared_story.publish_update_to_subscribers()
|