Updating subscribers of threads now works.
This commit is contained in:
parent
b9845a2dc1
commit
89e6f347cd
@ -100,8 +100,20 @@ def update(request):
|
||||
post = Post(content=item['Content'].strip(), date=dt, user_id=user_id)
|
||||
thread.posts.append(post)
|
||||
DBSession.add(post)
|
||||
for subscriber in thread.subscribers:
|
||||
subscriber.read = False
|
||||
|
||||
newSubscribers = request.json_body['Subscribers']
|
||||
for i in range(len(thread.subscribers), 0, -1):
|
||||
subscriber = thread.subscribers[i - 1]
|
||||
if subscriber.user.name not in newSubscribers:
|
||||
thread.subscribers.remove(subscriber)
|
||||
else:
|
||||
newSubscribers.remove(subscriber.name)
|
||||
subscriber.read = False
|
||||
for j in newSubscribers:
|
||||
subscriber = Subscriber(user_id=User.by_name(j).id, read=False)
|
||||
thread.subscribers.append(subscriber)
|
||||
DBSession.add(subscriber)
|
||||
|
||||
transaction.commit()
|
||||
return thread_info(thread.id)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user