Skip to content

Commit aa7c34e

Browse files
Patrick De La GarzaPatrick De La Garza
authored andcommitted
PATCH PEER TYPES
1 parent 1fd066e commit aa7c34e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

refiner/models/unrefined.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class MinerFwdFrom(BaseModel):
117117
flags: int
118118
imported: bool = False
119119
savedOut: bool = False
120-
fromId: Optional[MinerFromId] = None
120+
fromId: Optional[Any] = None
121121
fromName: Optional[str] = None
122122
date: int
123123
channelPost: Optional[int] = None
@@ -146,7 +146,7 @@ class MinerMessageData(BaseModel):
146146
post: Optional[bool] = False
147147
legacy: Optional[bool] = False
148148
id: int
149-
fromId: Optional[MinerFromId] = None
149+
fromId: Optional[Union[MinerFromId, PeerChannel, PeerChat]] = None
150150
peerId: Optional[MinerPeerId] = None
151151
fwdFrom: Optional[MinerFwdFrom] = None
152152
replyTo: Optional[MinerReplyTo] = None

refiner/transformer/miner_transformer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ def transform(self, data: Dict[str, Any]) -> List[Base]:
7676
for msg in chat_data.contents:
7777
if hasattr(msg, 'fromId') and msg.fromId and hasattr(msg.fromId, 'userId'):
7878
participants.add(msg.fromId.userId)
79+
if hasattr(msg, 'fromId') and msg.fromId and hasattr(msg.fromId, 'channelId'):
80+
participants.add(msg.fromId.channelId)
81+
if hasattr(msg, 'fromId') and msg.fromId and hasattr(msg.fromId, 'chatId'):
82+
participants.add(msg.fromId.chatId)
7983

8084
# Create SubmissionChat record
8185
chat_id = str(uuid.uuid4())
@@ -102,6 +106,10 @@ def transform(self, data: Dict[str, Any]) -> List[Base]:
102106
sender_id = "unknown"
103107
if hasattr(msg_content, 'fromId') and msg_content.fromId and hasattr(msg_content.fromId, 'userId'):
104108
sender_id = str(msg_content.fromId.userId)
109+
elif hasattr(msg_content, 'fromId') and msg_content.fromId and hasattr(msg_content.fromId, 'channelId'):
110+
sender_id = str(msg_content.fromId.channelId)
111+
elif hasattr(msg_content, 'fromId') and msg_content.fromId and hasattr(msg_content.fromId, 'chatId'):
112+
sender_id = str(msg_content.fromId.chatId)
105113

106114
# Get chat ID
107115
chat_source_id = str(chat_data.chat_id)

0 commit comments

Comments
 (0)