nicer way to handle no peers
This commit is contained in:
parent
eb11424003
commit
f16ac0e3c1
1 changed files with 3 additions and 7 deletions
|
@ -161,13 +161,9 @@ class User(db.Model):
|
||||||
if not was_peering:
|
if not was_peering:
|
||||||
Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
|
Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
|
||||||
if not 'index' in self.info:
|
if not 'index' in self.info:
|
||||||
qs = User.query.filter_by(peered=True)
|
self.info['index'] = max([
|
||||||
if qs.count():
|
u.info.get('index', -1) for u in User.query.filter_by(peered=True)
|
||||||
self.info['index'] = max([
|
] + [0]) + 1
|
||||||
u.info.get('index', -1) for u in qs
|
|
||||||
]) + 1
|
|
||||||
else:
|
|
||||||
self.info['index'] = 1
|
|
||||||
self.peered = True
|
self.peered = True
|
||||||
self.save()
|
self.save()
|
||||||
if self.id in state.removepeer:
|
if self.id in state.removepeer:
|
||||||
|
|
Loading…
Reference in a new issue