Merge branch 'master' into highlights

* master:
  Handling APNS unicode encode errors.
  Fixing APNS notifications.
  Attempting to corral APNS push notification max sizes due to chinese unicode characters being 3 bytes.
  Handling missing user sub folders for IFTTT.
  Handling missing original page.
  Handling mercury text parsing error.
  Fixing issue with double saving of classifier.
This commit is contained in:
Samuel Clay 2018-08-09 14:30:56 -04:00
commit 12ae6bcdae
5 changed files with 19 additions and 18 deletions

View file

@ -1,5 +1,4 @@
import urllib
import urlparse
import datetime
import lxml.html
import tweepy
@ -284,7 +283,12 @@ def api_user_info(request):
@json.json_view
def api_feed_list(request, trigger_slug=None):
user = request.user
usf = UserSubscriptionFolders.objects.get(user=user)
try:
usf = UserSubscriptionFolders.objects.get(user=user)
except UserSubscriptionFolders.DoesNotExist:
return {"errors": [{
'message': 'Could not find feeds for user.'
}]}
flat_folders = usf.flatten_folders()
titles = [dict(label=" - Folder: All Site Stories", value="all")]
feeds = {}

View file

@ -1,6 +1,7 @@
import requests
import urllib3
import zlib
from simplejson.decoder import JSONDecodeError
from requests.packages.urllib3.exceptions import LocationParseError
from socket import error as SocketError
from mongoengine.queryset import NotUniqueError
@ -69,8 +70,11 @@ class TextImporter:
if not resp:
return
doc = resp.json()
if doc.get('error', False):
try:
doc = resp.json()
except JSONDecodeError:
doc = None
if not doc or doc.get('error', False):
logging.user(self.request, "~SN~FRFailed~FY to fetch ~FGoriginal text~FY: %s" % doc.get('messages', "[unknown merucry error]"))
return

View file

@ -526,7 +526,8 @@ def original_story(request):
if not story:
logging.user(request, "~FYFetching ~FGoriginal~FY story page: ~FRstory not found")
return {'code': -1, 'message': 'Story not found.', 'original_page': None, 'failed': True}
# return {'code': -1, 'message': 'Story not found.', 'original_page': None, 'failed': True}
raise Http404
original_page = story.fetch_original_page(force=force, request=request, debug=debug)

View file

@ -1901,19 +1901,6 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
});
},
fetch_original_story_page: function(story_hash, callback, error_callback) {
var story = this.get_story(story_hash);
this.make_request('/rss_feeds/original_story', {
story_hash: story_hash
}, function(data) {
story.set('original_page', data.original_page);
callback(data);
}, error_callback, {
request_type: 'GET',
ajax_group: 'statistics'
});
},
recalculate_story_scores: function(feed_id, options) {
options = options || {};
this.stories.each(_.bind(function(story, i) {

View file

@ -272,6 +272,11 @@ def linkify(*args, **kwargs):
return xhtml_unescape_tornado(linkify_tornado(*args, **kwargs))
def truncate_chars(value, max_length):
if isinstance(value, unicode):
try:
value = value.encode('utf-8')
except UnicodeDecodeError:
pass
if len(value) <= max_length:
return value