fix resync
This commit is contained in:
parent
3845189b4c
commit
adf2eef34a
1 changed files with 6 additions and 6 deletions
|
@ -71,12 +71,13 @@ class Changelog(db.Model):
|
|||
logger.debug('record change: %s', c.json())
|
||||
|
||||
@classmethod
|
||||
def apply_changes(cls, user, changes, first=False):
|
||||
def apply_changes(cls, user_, changes, first=False):
|
||||
from user.models import User
|
||||
user = user_
|
||||
trigger = changes
|
||||
if trigger:
|
||||
trigger_event('change', {})
|
||||
if first:
|
||||
logger.debug('remove left over items')
|
||||
items = set()
|
||||
lists = {}
|
||||
peers = set()
|
||||
|
@ -103,12 +104,11 @@ class Changelog(db.Model):
|
|||
qs = user.lists.filter_by(name=name)
|
||||
if qs.count():
|
||||
l = qs[0]
|
||||
remove = []
|
||||
for i in l.get_items():
|
||||
if i.id not in lists[name]:
|
||||
remove.append(i.id)
|
||||
l.items.remove(i.id)
|
||||
for peer in user.models.Users.query:
|
||||
if i.id in l.items:
|
||||
l.items.remove(i.id)
|
||||
for peer in User.query:
|
||||
if user.id in peer.info.get('users', {}) and peer.id not in peers:
|
||||
del peer.info['users'][user.id]
|
||||
peer.save()
|
||||
|
|
Loading…
Reference in a new issue