forked from Hay1tsme/artemis
aimedb: fix idm zfill issue
This commit is contained in:
parent
8e39b56bae
commit
6ae11f96a2
@ -240,18 +240,19 @@ class AimedbServlette():
|
|||||||
used on the big boy networks.
|
used on the big boy networks.
|
||||||
"""
|
"""
|
||||||
req = ADBFelicaLookupRequest(data)
|
req = ADBFelicaLookupRequest(data)
|
||||||
card = await self.data.card.get_card_by_idm(req.idm)
|
idm = req.idm.zfill(16)
|
||||||
|
card = await self.data.card.get_card_by_idm(idm)
|
||||||
if not card:
|
if not card:
|
||||||
ac = self.data.card.to_access_code(req.idm)
|
ac = self.data.card.to_access_code(idm)
|
||||||
test = await self.data.card.get_card_by_access_code(ac)
|
test = await self.data.card.get_card_by_access_code(ac)
|
||||||
if test:
|
if test:
|
||||||
await self.data.card.set_idm_by_access_code(ac, req.idm)
|
await self.data.card.set_idm_by_access_code(ac, idm)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ac = card['access_code']
|
ac = card['access_code']
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
f"idm {req.idm} ipm {req.pmm} -> access_code {ac}"
|
f"idm {idm} ipm {req.pmm.zfill(16)} -> access_code {ac}"
|
||||||
)
|
)
|
||||||
return ADBFelicaLookupResponse.from_req(req.head, ac)
|
return ADBFelicaLookupResponse.from_req(req.head, ac)
|
||||||
|
|
||||||
@ -293,13 +294,14 @@ class AimedbServlette():
|
|||||||
async def handle_felica_lookup_ex(self, data: bytes, resp_code: int) -> bytes:
|
async def handle_felica_lookup_ex(self, data: bytes, resp_code: int) -> bytes:
|
||||||
req = ADBFelicaLookup2Request(data)
|
req = ADBFelicaLookup2Request(data)
|
||||||
user_id = None
|
user_id = None
|
||||||
card = await self.data.card.get_card_by_idm(req.idm)
|
idm = req.idm.zfill(16)
|
||||||
|
card = await self.data.card.get_card_by_idm(idm)
|
||||||
if not card:
|
if not card:
|
||||||
access_code = self.data.card.to_access_code(req.idm)
|
access_code = self.data.card.to_access_code(idm)
|
||||||
card = await self.data.card.get_card_by_access_code(access_code)
|
card = await self.data.card.get_card_by_access_code(access_code)
|
||||||
if card:
|
if card:
|
||||||
user_id = card['user']
|
user_id = card['user']
|
||||||
await self.data.card.set_idm_by_access_code(access_code, req.idm)
|
await self.data.card.set_idm_by_access_code(access_code, idm)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
user_id = card['user']
|
user_id = card['user']
|
||||||
@ -309,7 +311,7 @@ class AimedbServlette():
|
|||||||
user_id = -1
|
user_id = -1
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
f"idm {req.idm} ipm {req.pmm} -> access_code {access_code} user_id {user_id}"
|
f"idm {idm} ipm {req.pmm} -> access_code {access_code} user_id {user_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
resp = ADBFelicaLookup2Response.from_req(req.head, user_id, access_code)
|
resp = ADBFelicaLookup2Response.from_req(req.head, user_id, access_code)
|
||||||
|
Loading…
Reference in New Issue
Block a user