-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinsert_handler.ps1
More file actions
29 lines (29 loc) · 1.17 KB
/
Copy pathinsert_handler.ps1
File metadata and controls
29 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$lines = Get-Content 'linkup/messaging/consumers.py'
$insertPos = $null
for ($i = 0; $i -lt $lines.Count; $i++) {
if ($lines[$i] -like '*async def multi_tab_sync(self, event):*' -and $i -gt 1000) {
$insertPos = $i
break
}
}
if ($insertPos) {
$handler = @(
''
' async def read_receipt_update(self, event):'
' """Send read receipt update to WebSocket"""'
' try:'
' serialized_message = self.json_serializer.safe_serialize(event["message"])'
' await self.send(text_data=self.json_serializer.to_json_string(serialized_message))'
' except Exception as e:'
' MessagingLogger.log_error('
' f"Error in read_receipt_update handler: {e}",'
' context_data={"event": event, "user_id": self.user.id}'
' )'
''
)
$lines = $lines[0..($insertPos-1)] + $handler + $lines[$insertPos..($lines.Count-1)]
$lines | Set-Content 'linkup/messaging/consumers.py'
Write-Host 'Inserted read_receipt_update handler at line' $insertPos
} else {
Write-Host 'Could not find insertion point'
}