dont record changes from other users
increase protocol version to block outdated users.
This commit is contained in:
parent
980e68ccc6
commit
031665bc24
3 changed files with 12 additions and 5 deletions
|
@ -60,6 +60,7 @@ class Changelog(db.Model):
|
|||
state.db.session.commit()
|
||||
#if state.nodes:
|
||||
# state.nodes.queue('peered', 'pushChanges', [c.json()])
|
||||
logger.debug('record change: %s', c.json())
|
||||
|
||||
@classmethod
|
||||
def record_ts(cls, user, ts, action, *args):
|
||||
|
@ -76,6 +77,7 @@ class Changelog(db.Model):
|
|||
state.db.session.commit()
|
||||
#if state.nodes:
|
||||
# state.nodes.queue('peered', 'pushChanges', [c.json()])
|
||||
logger.debug('record change: %s', c.json())
|
||||
|
||||
@classmethod
|
||||
def apply_changes(cls, user, changes):
|
||||
|
@ -168,6 +170,10 @@ class Changelog(db.Model):
|
|||
if i.timestamp > timestamp:
|
||||
logger.debug('ignore edititem change %s %s %s', timestamp, itemid, meta)
|
||||
return True
|
||||
if state.user() in i.users:
|
||||
logger.debug('ignore edititem events for own items %s %s %s', timestamp, itemid, meta)
|
||||
logger.debug('----------------------item.modified: %s', i.modifed)
|
||||
return True
|
||||
primary = None
|
||||
if 'primaryid' in meta:
|
||||
primary = meta['primaryid']
|
||||
|
@ -294,7 +300,7 @@ class Changelog(db.Model):
|
|||
if not m or m.timestamp < timestamp:
|
||||
if not m:
|
||||
m = Metadata.get_or_create(key, value)
|
||||
if m.edit(data):
|
||||
if m.edit(data, False):
|
||||
m.update_items()
|
||||
user.clear_smart_list_cache()
|
||||
return True
|
||||
|
|
|
@ -738,7 +738,7 @@ class Metadata(db.Model):
|
|||
state.db.session.commit()
|
||||
self.update_items()
|
||||
|
||||
def edit(self, data):
|
||||
def edit(self, data, record=True):
|
||||
changed = {}
|
||||
for key in data:
|
||||
if key == 'id':
|
||||
|
@ -748,8 +748,9 @@ class Metadata(db.Model):
|
|||
changed[key] = data[key]
|
||||
if changed:
|
||||
self.save()
|
||||
user = state.user()
|
||||
Changelog.record(user, 'editmeta', self.key, self.value, changed)
|
||||
if record:
|
||||
user = state.user()
|
||||
Changelog.record(user, 'editmeta', self.key, self.value, changed)
|
||||
return changed
|
||||
|
||||
def update_items(self):
|
||||
|
|
|
@ -76,7 +76,7 @@ if 'modules' in release and 'openmedialibrary' in release['modules']:
|
|||
else:
|
||||
MINOR_VERSION = 'git'
|
||||
|
||||
NODE_PROTOCOL="0.2"
|
||||
NODE_PROTOCOL="0.3"
|
||||
VERSION="%s.%s" % (NODE_PROTOCOL, MINOR_VERSION)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue