|
|
@ -19,7 +19,6 @@ import logging |
|
|
|
import re |
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
from six import iterkeys |
|
|
|
from six import iterkeys |
|
|
|
from six.moves import range |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from twisted.internet import defer |
|
|
|
from twisted.internet import defer |
|
|
|
from twisted.internet.defer import Deferred |
|
|
|
from twisted.internet.defer import Deferred |
|
|
@ -482,12 +481,8 @@ class RegistrationWorkerStore(SQLBaseStore): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Gets the localpart of the next generated user ID. |
|
|
|
Gets the localpart of the next generated user ID. |
|
|
|
|
|
|
|
|
|
|
|
Generated user IDs are integers, and we aim for them to be as small as |
|
|
|
Generated user IDs are integers, so we find the largest integer user ID |
|
|
|
we can. Unfortunately, it's possible some of them are already taken by |
|
|
|
already taken and return that plus one. |
|
|
|
existing users, and there may be gaps in the already taken range. This |
|
|
|
|
|
|
|
function returns the start of the first allocatable gap. This is to |
|
|
|
|
|
|
|
avoid the case of ID 1000 being pre-allocated and starting at 1001 while |
|
|
|
|
|
|
|
0-999 are available. |
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
def _find_next_generated_user_id(txn): |
|
|
|
def _find_next_generated_user_id(txn): |
|
|
@ -503,9 +498,11 @@ class RegistrationWorkerStore(SQLBaseStore): |
|
|
|
match = regex.search(user_id) |
|
|
|
match = regex.search(user_id) |
|
|
|
if match: |
|
|
|
if match: |
|
|
|
found.add(int(match.group(1))) |
|
|
|
found.add(int(match.group(1))) |
|
|
|
for i in range(len(found) + 1): |
|
|
|
|
|
|
|
if i not in found: |
|
|
|
if not found: |
|
|
|
return i |
|
|
|
return 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return max(found) + 1 |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
( |
|
|
|
( |
|
|
|