diff --git a/apps/oauth/urls.py b/apps/oauth/urls.py index ec2a938b1..eb6d2144e 100644 --- a/apps/oauth/urls.py +++ b/apps/oauth/urls.py @@ -5,10 +5,8 @@ from oauth2_provider import views as op_views urlpatterns = patterns('', url(r'^twitter_connect/?$', views.twitter_connect, name='twitter-connect'), url(r'^facebook_connect/?$', views.facebook_connect, name='facebook-connect'), - url(r'^appdotnet_connect/?$', views.appdotnet_connect, name='appdotnet-connect'), url(r'^twitter_disconnect/?$', views.twitter_disconnect, name='twitter-disconnect'), url(r'^facebook_disconnect/?$', views.facebook_disconnect, name='facebook-disconnect'), - url(r'^appdotnet_disconnect/?$', views.appdotnet_disconnect, name='appdotnet-disconnect'), url(r'^follow_twitter_account/?$', views.follow_twitter_account, name='social-follow-twitter'), url(r'^unfollow_twitter_account/?$', views.unfollow_twitter_account, name='social-unfollow-twitter'), diff --git a/apps/oauth/views.py b/apps/oauth/views.py index c9fcb5b95..50b3d7009 100644 --- a/apps/oauth/views.py +++ b/apps/oauth/views.py @@ -11,7 +11,7 @@ from django.conf import settings from mongoengine.queryset import NotUniqueError from mongoengine.queryset import OperationError from apps.social.models import MSocialServices, MSocialSubscription, MSharedStory -from apps.social.tasks import SyncTwitterFriends, SyncFacebookFriends, SyncAppdotnetFriends +from apps.social.tasks import SyncTwitterFriends, SyncFacebookFriends from apps.reader.models import UserSubscription, UserSubscriptionFolders, RUserStory from apps.analyzer.models import MClassifierTitle, MClassifierAuthor, MClassifierFeed, MClassifierTag from apps.analyzer.models import compute_story_score @@ -23,7 +23,6 @@ from utils.view_functions import render_to from utils import urlnorm from utils import json_functions as json from vendor import facebook -from vendor import appdotnet @login_required @render_to('social/social_connect.xhtml') @@ -145,63 +144,6 @@ def facebook_connect(request): url = "https://www.facebook.com/dialog/oauth?" + urllib.urlencode(args) return {'next': url} -@login_required -@render_to('social/social_connect.xhtml') -def appdotnet_connect(request): - domain = Site.objects.get_current().domain - args = { - "client_id": settings.APPDOTNET_CLIENTID, - "client_secret": settings.APPDOTNET_SECRET, - "redirect_uri": "https://" + domain + - reverse('appdotnet-connect'), - "scope": ["email", "write_post", "follow"], - } - - oauth_code = request.REQUEST.get('code') - denied = request.REQUEST.get('denied') - if denied: - logging.user(request, "~BB~FRDenied App.net connect") - return {'error': 'Denied! Try connecting again.'} - elif oauth_code: - try: - adn_auth = appdotnet.Appdotnet(**args) - response = adn_auth.getAuthResponse(oauth_code) - adn_resp = json.decode(response) - access_token = adn_resp['access_token'] - adn_userid = adn_resp['user_id'] - except (IOError): - logging.user(request, "~BB~FRFailed App.net connect") - return dict(error="App.net has returned an error. Try connecting again.") - - # Be sure that two people aren't using the same Twitter account. - existing_user = MSocialServices.objects.filter(appdotnet_uid=unicode(adn_userid)) - if existing_user and existing_user[0].user_id != request.user.pk: - try: - user = User.objects.get(pk=existing_user[0].user_id) - logging.user(request, "~BB~FRFailed App.net connect, another user: %s" % user.username) - return dict(error=("Another user (%s, %s) has " - "already connected with those App.net credentials." - % (user.username, user.email or "no email"))) - except User.DoesNotExist: - existing_user.delete() - - social_services = MSocialServices.get_user(request.user.pk) - social_services.appdotnet_uid = unicode(adn_userid) - social_services.appdotnet_access_token = access_token - social_services.syncing_appdotnet = True - social_services.save() - - SyncAppdotnetFriends.delay(user_id=request.user.pk) - - logging.user(request, "~BB~FRFinishing App.net connect") - return {} - else: - # Start the OAuth process - adn_auth = appdotnet.Appdotnet(**args) - auth_url = adn_auth.generateAuthUrl() - logging.user(request, "~BB~FRStarting App.net connect") - return {'next': auth_url} - @ajax_login_required def twitter_disconnect(request): logging.user(request, "~BB~FRDisconnecting Twitter") @@ -217,15 +159,7 @@ def facebook_disconnect(request): social_services.disconnect_facebook() return HttpResponseRedirect(reverse('load-user-friends')) - -@ajax_login_required -def appdotnet_disconnect(request): - logging.user(request, "~BB~FRDisconnecting App.net") - social_services = MSocialServices.objects.get(user_id=request.user.pk) - social_services.disconnect_appdotnet() - - return HttpResponseRedirect(reverse('load-user-friends')) - + @ajax_login_required @json.json_view def follow_twitter_account(request): diff --git a/apps/social/models.py b/apps/social/models.py index 6e79d64e3..d7f6b4893 100644 --- a/apps/social/models.py +++ b/apps/social/models.py @@ -29,7 +29,6 @@ from apps.rss_feeds.text_importer import TextImporter from apps.rss_feeds.page_importer import PageImporter from apps.profile.models import Profile, MSentEmail from vendor import facebook -from vendor import appdotnet from vendor import pynliner from utils import log as logging from utils import json_functions as json @@ -2133,10 +2132,8 @@ class MSharedStory(mongo.DynamicDocument): if service == 'twitter': posted = social_service.post_to_twitter(self) - # elif service == 'facebook': - # posted = social_service.post_to_facebook(self) - elif service == 'appdotnet': - posted = social_service.post_to_appdotnet(self) + elif service == 'facebook': + posted = social_service.post_to_facebook(self) if posted: self.posted_to_services.append(service) @@ -2390,25 +2387,19 @@ class MSocialServices(mongo.Document): facebook_friend_ids = mongo.ListField(mongo.StringField()) facebook_picture_url = mongo.StringField() facebook_refresh_date = mongo.DateTimeField() - appdotnet_uid = mongo.StringField() - appdotnet_access_token= mongo.StringField() - appdotnet_friend_ids = mongo.ListField(mongo.StringField()) - appdotnet_picture_url = mongo.StringField() - appdotnet_refresh_date= mongo.DateTimeField() upload_picture_url = mongo.StringField() syncing_twitter = mongo.BooleanField(default=False) syncing_facebook = mongo.BooleanField(default=False) - syncing_appdotnet = mongo.BooleanField(default=False) meta = { 'collection': 'social_services', - 'indexes': ['user_id', 'twitter_friend_ids', 'facebook_friend_ids', 'twitter_uid', 'facebook_uid', 'appdotnet_uid'], + 'indexes': ['user_id', 'twitter_friend_ids', 'facebook_friend_ids', 'twitter_uid', 'facebook_uid'], 'allow_inheritance': False, } def __unicode__(self): user = User.objects.get(pk=self.user_id) - return "%s (Twitter: %s, FB: %s, ADN: %s)" % (user.username, self.twitter_uid, self.facebook_uid, self.appdotnet_uid) + return "%s (Twitter: %s, FB: %s)" % (user.username, self.twitter_uid, self.facebook_uid) def canonical(self): user = User.objects.get(pk=self.user_id) @@ -2424,11 +2415,6 @@ class MSocialServices(mongo.Document): 'facebook_picture_url': self.facebook_picture_url, 'syncing': self.syncing_facebook, }, - 'appdotnet': { - 'appdotnet_uid': self.appdotnet_uid, - 'appdotnet_picture_url': self.appdotnet_picture_url, - 'syncing': self.syncing_appdotnet, - }, 'gravatar': { 'gravatar_picture_url': "https://www.gravatar.com/avatar/" + \ hashlib.md5(user.email.lower()).hexdigest() @@ -2491,10 +2477,6 @@ class MSocialServices(mongo.Document): graph = facebook.GraphAPI(access_token=self.facebook_access_token, version="3.1") return graph - def appdotnet_api(self): - adn_api = appdotnet.Appdotnet(access_token=self.appdotnet_access_token) - return adn_api - def sync_twitter_friends(self): user = User.objects.get(pk=self.user_id) logging.user(user, "~BG~FMTwitter import starting...") @@ -2638,84 +2620,6 @@ class MSocialServices(mongo.Document): return following - def sync_appdotnet_friends(self): - user = User.objects.get(pk=self.user_id) - logging.user(user, "~BG~FMApp.net import starting...") - - api = self.appdotnet_api() - if not api: - logging.user(user, "~BG~FMApp.net import ~SBfailed~SN: no api access.") - self.syncing_appdotnet = False - self.save() - return - - friend_ids = [] - has_more_friends = True - before_id = None - since_id = None - while has_more_friends: - friends_resp = api.getUserFollowingIds(self.appdotnet_uid, - before_id=before_id, - since_id=since_id) - friends = json.decode(friends_resp) - before_id = friends['meta'].get('min_id') - since_id = friends['meta'].get('max_id') - has_more_friends = friends['meta'].get('more') - friend_ids.extend([fid for fid in friends['data']]) - - if not friend_ids: - logging.user(user, "~BG~FMApp.net import ~SBfailed~SN: no friend_ids.") - self.syncing_appdotnet = False - self.save() - return - - adn_user = json.decode(api.getUser(self.appdotnet_uid))['data'] - self.appdotnet_picture_url = adn_user['avatar_image']['url'] - self.appdotnet_username = adn_user['username'] - self.appdotnet_friend_ids = friend_ids - self.appdotnet_refreshed_date = datetime.datetime.utcnow() - self.syncing_appdotnet = False - self.save() - - profile = MSocialProfile.get_user(self.user_id) - profile.bio = profile.bio or adn_user['description']['text'] - profile.save() - profile.count_follows() - - if not profile.photo_url or not profile.photo_service: - self.set_photo('appdotnet') - - self.follow_appdotnet_friends() - - def follow_appdotnet_friends(self): - social_profile = MSocialProfile.get_user(self.user_id) - following = [] - followers = 0 - - if not self.autofollow: - return following - - # Follow any friends already on NewsBlur - user_social_services = MSocialServices.objects.filter(appdotnet_uid__in=self.appdotnet_friend_ids) - for user_social_service in user_social_services: - followee_user_id = user_social_service.user_id - socialsub = social_profile.follow_user(followee_user_id) - if socialsub: - following.append(followee_user_id) - - # Friends already on NewsBlur should follow back - # following_users = MSocialServices.objects.filter(appdotnet_friend_ids__contains=self.appdotnet_uid) - # for following_user in following_users: - # if following_user.autofollow: - # following_user_profile = MSocialProfile.get_user(following_user.user_id) - # following_user_profile.follow_user(self.user_id, check_unfollowed=True) - # followers += 1 - - user = User.objects.get(pk=self.user_id) - logging.user(user, "~BG~FMApp.net import: %s users, now following ~SB%s~SN with ~SB%s~SN follower-backs" % (len(self.appdotnet_friend_ids), len(following), followers)) - - return following - def disconnect_twitter(self): self.syncing_twitter = False self.twitter_uid = None @@ -2726,11 +2630,6 @@ class MSocialServices(mongo.Document): self.facebook_uid = None self.save() - def disconnect_appdotnet(self): - self.syncing_appdotnet = False - self.appdotnet_uid = None - self.save() - def set_photo(self, service): profile = MSocialProfile.get_user(self.user_id) if service == 'nothing': @@ -2857,21 +2756,6 @@ class MSocialServices(mongo.Document): return return True - - def post_to_appdotnet(self, shared_story): - message = shared_story.generate_post_to_service_message(truncate=256) - - try: - api = self.appdotnet_api() - api.createPost(text=message, links=[{ - 'text': shared_story.decoded_story_title, - 'url': shared_story.blurblog_permalink() - }]) - except Exception, e: - print e - return - - return True class MInteraction(mongo.Document): diff --git a/apps/social/tasks.py b/apps/social/tasks.py index bf60c0281..dcfdce7a2 100644 --- a/apps/social/tasks.py +++ b/apps/social/tasks.py @@ -55,13 +55,7 @@ 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' diff --git a/apps/social/views.py b/apps/social/views.py index be752e9ed..c6d92f2bf 100644 --- a/apps/social/views.py +++ b/apps/social/views.py @@ -660,11 +660,7 @@ def mark_story_as_shared(request): if post_to_services: for service in post_to_services: if service not in shared_story.posted_to_services: - if service == 'appdotnet': - # XXX TODO: Remove. Only for www->dev. - shared_story.post_to_service(service) - else: - PostToService.delay(shared_story_id=shared_story.id, service=service) + PostToService.delay(shared_story_id=shared_story.id, service=service) if shared_story.source_user_id and shared_story.comments: EmailStoryReshares.apply_async(kwargs=dict(shared_story_id=shared_story.id), diff --git a/media/css/reader.css b/media/css/reader.css index c913b0408..458c53ce3 100644 --- a/media/css/reader.css +++ b/media/css/reader.css @@ -4023,8 +4023,7 @@ body { overflow: hidden; } .NB-sideoption-share .NB-sideoption-share-crosspost-twitter, -.NB-sideoption-share .NB-sideoption-share-crosspost-facebook, -.NB-sideoption-share .NB-sideoption-share-crosspost-appdotnet { +.NB-sideoption-share .NB-sideoption-share-crosspost-facebook { float: left; width: 32px; height: 24px; @@ -4041,10 +4040,6 @@ body { background: transparent url('/media/embed/reader/facebook_service_off.png') no-repeat center center; background-size: 12px; } -.NB-sideoption-share .NB-sideoption-share-crosspost-appdotnet { - background: transparent url('/media/embed/reader/appdotnet_service_off.png') no-repeat center center; - background-size: 12px; -} .NB-sideoption-share .NB-sideoption-share-crosspost-twitter.NB-active, .NB-sideoption-share .NB-sideoption-share-crosspost-twitter:hover { background: transparent url('/media/embed/reader/twitter_service.png') no-repeat center center; @@ -4059,13 +4054,6 @@ body { border-color: #6884CD; background-color: rgba(104, 132, 205, .1); } -.NB-sideoption-share .NB-sideoption-share-crosspost-appdotnet.NB-active, -.NB-sideoption-share .NB-sideoption-share-crosspost-appdotnet:hover { - background: transparent url('/media/embed/reader/appdotnet_service.png') no-repeat center center; - background-size: 12px; - border-color: #D16857; - background-color: rgba(209, 104, 87, .1); -} .NB-sideoption-share .NB-sideoption-share-crosspost-text { font-size: 9px; text-transform: uppercase; diff --git a/media/js/newsblur/reader/reader_utils.js b/media/js/newsblur/reader/reader_utils.js index ea3a256de..f563b970f 100644 --- a/media/js/newsblur/reader/reader_utils.js +++ b/media/js/newsblur/reader/reader_utils.js @@ -6,8 +6,6 @@ NEWSBLUR.utils = { return 'Twitter'; case 'facebook': return 'Facebook'; - case 'appdotnet': - return 'App.net'; } }, diff --git a/media/js/newsblur/views/story_share_view.js b/media/js/newsblur/views/story_share_view.js index 635c88482..150025725 100644 --- a/media/js/newsblur/views/story_share_view.js +++ b/media/js/newsblur/views/story_share_view.js @@ -6,7 +6,6 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ "click .NB-sideoption-share-unshare" : "mark_story_as_unshared", "click .NB-sideoption-share-crosspost-twitter" : "toggle_twitter", "click .NB-sideoption-share-crosspost-facebook" : "toggle_facebook", - "click .NB-sideoption-share-crosspost-appdotnet" : "toggle_appdotnet", "keypress .NB-sideoption-share-comments" : "autosize", "keyup .NB-sideoption-share-comments" : "update_share_button_label", "keydown .NB-sideoption-share-comments" : "maybe_close" @@ -35,8 +34,7 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ \ <% if (!profile.get("private") && \ ((social_services.twitter && social_services.twitter.twitter_uid) || \ - (social_services.facebook && social_services.facebook.facebook_uid) || \ - (social_services.facebook && social_services.facebook.appdotnet_uid))) { %>\ + (social_services.facebook && social_services.facebook.facebook_uid))) { %>\