matrix: widen sync event window backwards — sender precedes type marker
This commit is contained in:
1 parent
a6d4e29589
commit
77f3150af4
1 file changed
+4
-1
+4
-1
@@ -121,8 +121,11 @@ pub fn sync(alloc: std.mem.Allocator, io: Io, token: []const u8, since: []const
|
||||
var i: usize = 0;
|
||||
while (std.mem.indexOfPos(u8, resp, i, "\"m.room.message\"")) |pos| {
|
||||
defer i = pos + 15;
|
||||
// Event layout: sender (and event_id) come BEFORE the type marker,
|
||||
// body comes after it in content — window spans both sides.
|
||||
const win_start = pos -| 600;
|
||||
const win_end = @min(resp.len, pos + 1500);
|
||||
const win = resp[pos..win_end];
|
||||
const win = resp[win_start..win_end];
|
||||
const sender = letta.jsonStr(alloc, win, 0, "sender") orelse continue;
|
||||
const body = letta.jsonStr(alloc, win, 0, "body") orelse {
|
||||
alloc.free(sender.val);
|
||||
|
||||
Reference in new issue
Block a user