0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 08:23:47 +01:00
This commit is contained in:
Erik Johnston 2017-06-27 15:53:45 +01:00
parent 78cefd78d6
commit 8c23221666
5 changed files with 9 additions and 12 deletions

View file

@ -200,7 +200,7 @@ class Auth(object):
)[0]
if user and access_token and ip_addr:
self.store.insert_client_ip(
user=user,
user_id=user.to_string(),
access_token=access_token,
ip=ip_addr,
user_agent=user_agent,

View file

@ -29,9 +29,8 @@ class SlavedClientIpStore(BaseSlavedStore):
max_entries=50000 * CACHE_SIZE_FACTOR,
)
def insert_client_ip(self, user, access_token, ip, user_agent, device_id):
def insert_client_ip(self, user_id, access_token, ip, user_agent, device_id):
now = int(self._clock.time_msec())
user_id = user.to_string()
key = (user_id, access_token, ip)
try:

View file

@ -58,9 +58,11 @@ class ClientIpStore(background_updates.BackgroundUpdateStore):
)
reactor.addSystemEventTrigger("before", "shutdown", self._update_client_ips_batch)
def insert_client_ip(self, user, access_token, ip, user_agent, device_id):
now = int(self._clock.time_msec())
key = (user.to_string(), access_token, ip)
def insert_client_ip(self, user_id, access_token, ip, user_agent, device_id,
now=None):
if not now:
now = int(self._clock.time_msec())
key = (user_id, access_token, ip)
try:
last_seen = self.client_ip_last_seen.get(key)

View file

@ -19,7 +19,6 @@ import synapse.api.errors
import synapse.handlers.device
import synapse.storage
from synapse import types
from tests import unittest, utils
user1 = "@boris:aaa"
@ -179,6 +178,6 @@ class DeviceTestCase(unittest.TestCase):
if ip is not None:
yield self.store.insert_client_ip(
types.UserID.from_string(user_id),
user_id,
access_token, ip, "user_agent", device_id)
self.clock.advance_time(1000)

View file

@ -15,9 +15,6 @@
from twisted.internet import defer
import synapse.server
import synapse.storage
import synapse.types
import tests.unittest
import tests.utils
@ -39,7 +36,7 @@ class ClientIpStoreTestCase(tests.unittest.TestCase):
self.clock.now = 12345678
user_id = "@user:id"
yield self.store.insert_client_ip(
synapse.types.UserID.from_string(user_id),
user_id,
"access_token", "ip", "user_agent", "device_id",
)