mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Reloading user feeds when receiving a new newsletter.
This commit is contained in:
parent
1043fa45aa
commit
db2dbcd053
2 changed files with 13 additions and 4 deletions
|
@ -53,9 +53,14 @@ class EmailNewsletter:
|
|||
feed_address=feed_address,
|
||||
folder='Newsletters'
|
||||
)
|
||||
r = redis.Redis(connection_pool=settings.REDIS_PUBSUB_POOL)
|
||||
r.publish(user.username, 'reload:feeds')
|
||||
|
||||
story_hash = MStory.ensure_story_hash(params['signature'], feed.pk)
|
||||
story_content = self.get_content(params)
|
||||
plain_story_content = self.get_content(params, force_plain=True)
|
||||
if len(plain_story_content) > len(story_content):
|
||||
story_content = plain_story_content
|
||||
story_content = self.clean_content(story_content)
|
||||
story_params = {
|
||||
"story_feed_id": feed.pk,
|
||||
|
@ -116,8 +121,10 @@ class EmailNewsletter:
|
|||
|
||||
return sender_name, sender_username, sender_domain
|
||||
|
||||
def get_content(self, params):
|
||||
if 'body-html' in params:
|
||||
def get_content(self, params, force_plain=False):
|
||||
if 'body-enriched' in params and not force_plain:
|
||||
return params['body-enriched']
|
||||
if 'body-html' in params and not force_plain:
|
||||
return params['body-html']
|
||||
if 'stripped-html' in params:
|
||||
return linkify(linebreaks(params['stripped-html']))
|
||||
|
|
|
@ -36,13 +36,15 @@ def newsletter_receive(request):
|
|||
# 'Content-Type':'multipart/mixed; boundary="------------020601070403020003080006"',
|
||||
# 'Subject':'Test Newsletter #1'
|
||||
# }
|
||||
params = request.REQUEST
|
||||
|
||||
response = HttpResponse('OK')
|
||||
|
||||
if settings.DEBUG:
|
||||
logging.debug(" ---> Email newsletter: %s" % pprint(request.REQUEST))
|
||||
logging.debug(" ---> Email newsletter: %s" % pprint(params))
|
||||
|
||||
email_newsletter = EmailNewsletter()
|
||||
story = email_newsletter.receive_newsletter(request.REQUEST)
|
||||
story = email_newsletter.receive_newsletter(params)
|
||||
|
||||
if not story:
|
||||
raise Http404
|
||||
|
|
Loading…
Add table
Reference in a new issue