subscription fixes
This commit is contained in:
parent
7ef0b9dc7d
commit
58dd9fb439
@ -46,8 +46,9 @@ def thread(slug):
|
|||||||
'user_id': get_active_user().id,
|
'user_id': get_active_user().id,
|
||||||
})
|
})
|
||||||
if subscription:
|
if subscription:
|
||||||
|
if int(posts[-1]['created_at']) > int(subscription.last_seen):
|
||||||
subscription.update({
|
subscription.update({
|
||||||
'last_seen': int(time.time())
|
'last_seen': int(posts[-1]['created_at'])
|
||||||
})
|
})
|
||||||
is_subscribed = True
|
is_subscribed = True
|
||||||
|
|
||||||
@ -78,6 +79,13 @@ def reply(slug):
|
|||||||
post_content = request.form['post_content']
|
post_content = request.form['post_content']
|
||||||
post = create_post(thread.id, user.id, post_content)
|
post = create_post(thread.id, user.id, post_content)
|
||||||
|
|
||||||
|
subscription = Subscriptions.find({'user_id': user.id, 'thread_id': thread.id})
|
||||||
|
|
||||||
|
if subscription:
|
||||||
|
subscription.update({'last_seen': int(time.time())})
|
||||||
|
elif request.form.get('subscribe', default=None) == 'on':
|
||||||
|
Subscriptions.create({'user_id': user.id, 'thread_id': thread.id, 'last_seen': int(time.time())})
|
||||||
|
|
||||||
return redirect(url_for(".thread", slug=slug, after=post.id, _anchor="latest-post"))
|
return redirect(url_for(".thread", slug=slug, after=post.id, _anchor="latest-post"))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user