/**
* This function throws an error, if you're not a room member.
*
* Expected return values:
*
* {
* "is_joined": false,
* "user_info": null
* }
*
* or
*
* {
* "is_member": true,
* "user_info": {
* "avatar_url": "mxc://matrix.org/abc123",
* "display_name": "Jane Doe"
* }
* }
*/
type Matrix = {
baseUrl: string;
token: string;
};
export async function main(
matrix_res: Matrix,
room_id: string,
user_id: string,
) {
const url = `${
matrix_res.baseUrl
}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/joined_members`;
const resp = await fetch(url, {
headers: {
Authorization: `Bearer ${matrix_res.token}`,
},
});
if (!resp.ok) {
throw Error(`Failed to fetch joined member list: Error HTTP${resp.status}`);
}
const data = await resp.json();
return {
is_joined: user_id in data?.joined,
user_info: data?.joined?.[user_id],
};
}
Submitted by admin 497 days ago
/**
* This function throws an error, if you're not a room member.
*
* Expected return values:
*
* {
* "is_joined": false,
* "user_info": null
* }
*
* or
*
* {
* "is_member": true,
* "user_info": {
* "avatar_url": "mxc://matrix.org/abc123",
* "display_name": "Jane Doe"
* }
* }
*/
type Matrix = {
baseUrl: string;
token: string;
};
export async function main(
matrix_res: Matrix,
room_id: string,
user_id: string,
) {
const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/joined_members`;
const resp = await fetch(url, {
headers: {
"Authorization": `Bearer ${matrix_res.token}`,
},
});
if (!resp.ok) {
throw Error(`Failed to fetch joined member list: Error HTTP${resp.status}`);
}
const data = await resp.json();
return {
is_joined: user_id in data?.joined,
user_info: data?.joined?.[user_id],
};
}
Submitted by admin 500 days ago
import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts"
/**
* This function throws an error, if you're not a room member.
*
* Expected return values:
*
* {
* "is_joined": false,
* "user_info": null
* }
*
* or
*
* {
* "is_member": true,
* "user_info": {
* "avatar_url": "mxc://matrix.org/abc123",
* "display_name": "Jane Doe"
* }
* }
*/
export async function main(
matrix_res: wmill.Resource<"matrix">,
room_id: string,
user_id: string,
) {
const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/joined_members`;
const resp = await fetch(url, {
headers: {
"Authorization": `Bearer ${matrix_res.token}`,
},
});
if (!resp.ok) {
throw Error(`Failed to fetch joined member list: Error HTTP${resp.status}`);
}
const data = await resp.json();
return {
is_joined: user_id in data?.joined,
user_info: data?.joined?.[user_id],
};
}
Submitted by adam186 628 days ago
import * as wmill from "https://deno.land/x/windmill@v1.70.1/mod.ts"
/**
* This function throws an error, if you're not a room member.
*
* Expected return values:
*
* {
* "is_joined": false,
* "user_info": null
* }
*
* or
*
* {
* "is_member": true,
* "user_info": {
* "avatar_url": "mxc://matrix.org/abc123",
* "display_name": "Jane Doe"
* }
* }
*/
export async function main(
matrix_res: wmill.Resource<"matrix">,
room_id: string,
user_id: string,
) {
const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/joined_members`;
const resp = await fetch(url, {
headers: {
"Authorization": `Bearer ${matrix_res.token}`,
},
});
if (!resp.ok) {
throw Error(`Failed to fetch joined member list: Error HTTP${resp.status}`);
}
const data = await resp.json();
return {
is_joined: user_id in data?.joined,
user_info: data?.joined?.[user_id],
};
}
Submitted by adam186 663 days ago
import * as wmill from "https://deno.land/x/windmill@v1.47.3/mod.ts"
/**
* This function throws an error, if you're not a room member.
*
* Expected return values:
*
* {
* "is_joined": false,
* "user_info": null
* }
*
* or
*
* {
* "is_member": true,
* "user_info": {
* "avatar_url": "mxc://matrix.org/abc123",
* "display_name": "Jane Doe"
* }
* }
*/
export async function main(
matrix_res: wmill.Resource<"matrix">,
room_id: string,
user_id: string,
) {
const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/joined_members`;
const resp = await fetch(url, {
headers: {
"Authorization": `Bearer ${matrix_res.token}`,
},
});
if (!resp.ok) {
throw Error(`Failed to fetch joined member list: Error HTTP${resp.status}`);
}
const data = await resp.json();
return {
is_joined: user_id in data?.joined,
user_info: data?.joined?.[user_id],
};
}
Submitted by jaller94 766 days ago