remove extra app context from fetch_reply_contexts
was causing detached state issues in previous commit
This commit is contained in:
parent
ddb75f5993
commit
4f11bb9f27
1 changed files with 17 additions and 19 deletions
|
@ -17,6 +17,7 @@ import requests
|
||||||
import rq
|
import rq
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
# normal update interval for polling feeds
|
# normal update interval for polling feeds
|
||||||
|
@ -94,6 +95,8 @@ def tick():
|
||||||
q.enqueue(update_feed, feed.id)
|
q.enqueue(update_feed, feed.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_feed(feed_id, content=None,
|
def update_feed(feed_id, content=None,
|
||||||
content_type=None, is_polling=True):
|
content_type=None, is_polling=True):
|
||||||
|
|
||||||
|
@ -224,10 +227,6 @@ def update_feed(feed_id, content=None,
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
if new_entries:
|
if new_entries:
|
||||||
|
|
||||||
for e in new_entries:
|
|
||||||
current_app.logger.debug('entry %s state: %s', e.uid, sqlalchemy.inspect(e))
|
|
||||||
|
|
||||||
notify_feed_updated(app, feed_id, new_entries)
|
notify_feed_updated(app, feed_id, new_entries)
|
||||||
|
|
||||||
|
|
||||||
|
@ -545,23 +544,22 @@ def hentry_to_entry(hentry, feed, backfill, now):
|
||||||
|
|
||||||
|
|
||||||
def fetch_reply_context(entry, in_reply_to, now):
|
def fetch_reply_context(entry, in_reply_to, now):
|
||||||
with flask_app():
|
context = Entry.query\
|
||||||
context = Entry.query\
|
.join(Entry.feed)\
|
||||||
.join(Entry.feed)\
|
.filter(Entry.permalink==in_reply_to, Feed.type == 'html')\
|
||||||
.filter(Entry.permalink==in_reply_to, Feed.type == 'html')\
|
.first()
|
||||||
.first()
|
|
||||||
|
|
||||||
if not context:
|
if not context:
|
||||||
current_app.logger.info('fetching in-reply-to url: %s',
|
current_app.logger.info('fetching in-reply-to url: %s',
|
||||||
in_reply_to)
|
in_reply_to)
|
||||||
parsed = mf2util.interpret(
|
parsed = mf2util.interpret(
|
||||||
mf2py.parse(url=proxy_url(in_reply_to)), in_reply_to)
|
mf2py.parse(url=proxy_url(in_reply_to)), in_reply_to)
|
||||||
if parsed:
|
if parsed:
|
||||||
context = hentry_to_entry(parsed, None, False, now)
|
context = hentry_to_entry(parsed, None, False, now)
|
||||||
db.session.add(context)
|
db.session.add(context)
|
||||||
|
|
||||||
if context:
|
if context:
|
||||||
entry.reply_context.append(context)
|
entry.reply_context.append(context)
|
||||||
|
|
||||||
|
|
||||||
def proxy_url(url):
|
def proxy_url(url):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue