matrix: authed v1 media download — homeserver has unauthenticated media disabled (MSC3916) (Pierre De Lancre)

This commit is contained in:
pierre committed 2026-10-02 02:41:12 +03:00
1 parent 7fabeeef91
commit 9f7b573d01
1 file changed
+3 -1
+3 -1
View File
@@ -120,7 +120,9 @@ pub fn downloadFile(alloc: std.mem.Allocator, io: Io, token: []const u8, mxc: []
const slash = std.mem.indexOfScalar(u8, rest, '/') orelse return error.BadMxc; const slash = std.mem.indexOfScalar(u8, rest, '/') orelse return error.BadMxc;
const server = rest[0..slash]; const server = rest[0..slash];
const media_id = rest[slash + 1 ..]; const media_id = rest[slash + 1 ..];
const url = try std.fmt.allocPrint(alloc, "{s}/_matrix/media/v3/download/{s}/{s}?allow_redirect=true", .{ HOMESERVER, server, media_id }); // MSC3916: homeserver has unauthenticated media disabled — use the
// authed client v1 endpoint (v3 download returns M_FORBIDDEN).
const url = try std.fmt.allocPrint(alloc, "{s}/_matrix/client/v1/media/download/{s}/{s}", .{ HOMESERVER, server, media_id });
defer alloc.free(url); defer alloc.free(url);
const resp = try httpRaw(alloc, io, "GET", url, token, "", null); const resp = try httpRaw(alloc, io, "GET", url, token, "", null);
// Error responses are small JSON with errcode — detect and report. // Error responses are small JSON with errcode — detect and report.