Skip to content

Commit

Permalink
[!] sns texts v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed Nov 10, 2024
1 parent 08697a9 commit 4640fa5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/model/snsname.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-11-07 20:16:19
LastEditors: Zella Zhong
LastEditTime: 2024-11-07 20:20:41
LastEditTime: 2024-11-10 22:54:37
FilePath: /data_service/src/model/snsname.py
Description:
'''
Expand Down Expand Up @@ -45,4 +45,5 @@ class SnsModel(Base):
update_time: DateTime = Column(DateTime, nullable=False)
texts: dict = Column(JSON, nullable=True)
resolved_records: dict = Column(JSON, nullable=True)
twitter_handle: str = Column(String, nullable=True)
twitter_handle: str = Column(String, nullable=True)
texts_v2: dict = Column(JSON, nullable=True)
18 changes: 9 additions & 9 deletions src/resolver/sns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-11-07 19:55:46
LastEditors: Zella Zhong
LastEditTime: 2024-11-07 23:13:07
LastEditTime: 2024-11-10 23:07:06
FilePath: /data_service/src/resolver/sns.py
Description:
'''
Expand Down Expand Up @@ -392,14 +392,14 @@ async def batch_query_sns_profile_by_id_from_db(query_ids) -> typing.List[Ident
display_name = name
avatar = None
description = None
texts = profile_record.texts

if texts:
# Filter out empty strings and decode non-empty texts
process_texts = {key: unquote(text, 'utf-8') for key, text in texts.items() if text != ""}
avatar = process_texts.get("avatar", None)
description = process_texts.get("description", None)
display_name = process_texts.get("name", name)

texts = None
texts_v2 = profile_record.texts_v2
if texts_v2:
process_texts = {key: unquote(text, 'utf-8') for key, text in texts_v2.items() if text != ""}
avatar = process_texts.get("pic", None)
if avatar is not None:
del process_texts["pic"]
texts = process_texts

if not texts:
Expand Down
19 changes: 10 additions & 9 deletions src/resolver/solana.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-07 23:11:29
LastEditors: Zella Zhong
LastEditTime: 2024-11-10 07:29:59
LastEditTime: 2024-11-10 23:07:49
FilePath: /data_service/src/resolver/solana.py
Description:
'''
Expand Down Expand Up @@ -312,18 +312,19 @@ async def batch_query_profile_by_address_db(query_ids) -> typing.List[IdentityRe
display_name = name
avatar = None
description = None
texts = profile_record.texts
if texts:
# Filter out empty strings and decode non-empty texts
process_texts = {key: unquote(text, 'utf-8') for key, text in texts.items() if text != ""}
avatar = process_texts.get("avatar", None)
description = process_texts.get("description", None)
display_name = process_texts.get("name", name)

texts = None
texts_v2 = profile_record.texts_v2
if texts_v2:
process_texts = {key: unquote(text, 'utf-8') for key, text in texts_v2.items() if text != ""}
avatar = process_texts.get("pic", None)
if avatar is not None:
del process_texts["pic"]
texts = process_texts

if not texts:
texts = None

twitter_handle = profile_record.twitter_handle
if twitter_handle:
if texts is not None:
Expand Down

0 comments on commit 4640fa5

Please sign in to comment.