Serialize user ip command as json

pull/2309/head
Erik Johnston 2017-06-27 16:25:38 +01:00
parent 8c23221666
commit 27f26e48b7
1 changed files with 9 additions and 5 deletions

View File

@ -323,14 +323,18 @@ class UserIpCommand(Command):
@classmethod @classmethod
def from_line(cls, line): def from_line(cls, line):
user_id, access_token, ip, device_id, last_seen, user_agent = line.split(" ", 5) user_id, jsn = line.split(" ", 1)
return cls(user_id, access_token, ip, user_agent, device_id, int(last_seen)) access_token, ip, user_agent, device_id, last_seen = json.loads(jsn)
return cls(
user_id, access_token, ip, user_agent, device_id, last_seen
)
def to_line(self): def to_line(self):
return " ".join(( return self.user_id + " " + json.dumps((
self.user_id, self.access_token, self.ip, self.device_id, self.access_token, self.ip, self.user_agent, self.device_id,
str(self.last_seen), self.user_agent, self.last_seen,
)) ))