subscription fixes
This commit is contained in:
		@@ -46,9 +46,10 @@ def thread(slug):
 | 
			
		||||
            'user_id': get_active_user().id,
 | 
			
		||||
        })
 | 
			
		||||
        if subscription:
 | 
			
		||||
            subscription.update({
 | 
			
		||||
                'last_seen': int(time.time())
 | 
			
		||||
            })
 | 
			
		||||
            if int(posts[-1]['created_at']) > int(subscription.last_seen):
 | 
			
		||||
                subscription.update({
 | 
			
		||||
                    'last_seen': int(posts[-1]['created_at'])
 | 
			
		||||
                })
 | 
			
		||||
            is_subscribed = True
 | 
			
		||||
 | 
			
		||||
    return render_template(
 | 
			
		||||
@@ -78,6 +79,13 @@ def reply(slug):
 | 
			
		||||
    post_content = request.form['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"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user