type Matrix = {
  baseUrl: string;
  token: string;
};
export async function main(
  matrix_res: Matrix,
  room_id: string,
  type: string,
  state_key?: string,
  json_content: string,
) {
  let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(
    room_id,
  )}/state/${encodeURIComponent(type)}/`;
  if (state_key) {
    url += encodeURIComponent(state_key);
  }
  const resp = await fetch(url, {
    method: "PUT",
    headers: {
      Authorization: `Bearer ${matrix_res.token}`,
      "Content-Type": "application/json",
    },
    body: json_content,
  });
  if (!resp.ok) {
    throw Error(`Failed to read room state: Error HTTP${resp.status}`);
  }
  return await resp.json();
}
 Submitted by hugo697 181 days ago
type Matrix = {
  baseUrl: string;
  token: string;
};
export async function main(
  matrix_res: Matrix,
  room_id: string,
  type: string,
  state_key?: string,
  json_content: string,
) {
  let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(
    room_id,
  )}/state/${encodeURIComponent(type)}/`;
  if (state_key) {
    url += encodeURIComponent(state_key);
  }
  const resp = await fetch(url, {
    method: "PUT",
    headers: {
      Authorization: `Bearer ${matrix_res.token}`,
      "Content-Type": "application/json",
    },
    body: json_content,
  });
  if (!resp.ok) {
    throw Error(`Failed to read room state: Error HTTP${resp.status}`);
  }
  return await resp.json();
}
 Submitted by admin 814 days ago
type Matrix = {
  baseUrl: string;
  token: string;
};
export async function main(
    matrix_res: Matrix,
    room_id: string,
    type: string,
    state_key?: string,
    json_content: string,
) {
    let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/${encodeURIComponent(type)}/`;
    if (state_key) {
        url += encodeURIComponent(state_key);
    }
    const resp = await fetch(url, {
        method: 'PUT',
        headers: {
            "Authorization": `Bearer ${matrix_res.token}`,
            "Content-Type": "application/json",
        },
        body: json_content,
    });
    if (!resp.ok) {
        throw Error(`Failed to read room state: Error HTTP${resp.status}`);
    }
    return await resp.json();
}
 Submitted by admin 817 days ago
import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts";
export async function main(
    matrix_res: wmill.Resource<"matrix">,
    room_id: string,
    type: string,
    state_key?: string,
    json_content: string,
) {
    let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/${encodeURIComponent(type)}/`;
    if (state_key) {
        url += encodeURIComponent(state_key);
    }
    const resp = await fetch(url, {
        method: 'PUT',
        headers: {
            "Authorization": `Bearer ${matrix_res.token}`,
            "Content-Type": "application/json",
        },
        body: json_content,
    });
    if (!resp.ok) {
        throw Error(`Failed to read room state: Error HTTP${resp.status}`);
    }
    return await resp.json();
}
 Submitted by adam186 945 days ago
import * as wmill from "https://deno.land/x/windmill@v1.70.1/mod.ts";
export async function main(
    matrix_res: wmill.Resource<"matrix">,
    room_id: string,
    type: string,
    state_key?: string,
    json_content: string,
) {
    let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/${encodeURIComponent(type)}/`;
    if (state_key) {
        url += encodeURIComponent(state_key);
    }
    const resp = await fetch(url, {
        method: 'PUT',
        headers: {
            "Authorization": `Bearer ${matrix_res.token}`,
            "Content-Type": "application/json",
        },
        body: json_content,
    });
    if (!resp.ok) {
        throw Error(`Failed to read room state: Error HTTP${resp.status}`);
    }
    return await resp.json();
}
 Submitted by adam186 980 days ago
import * as wmill from "https://deno.land/x/windmill@v1.35.0/mod.ts";
export async function main(
    matrix_res: wmill.Resource<"matrix">,
    room_id: string,
    type: string,
    state_key?: string,
    json_content: string,
) {
    let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/${encodeURIComponent(type)}/`;
    if (state_key) {
        url += encodeURIComponent(state_key);
    }
    const resp = await fetch(url, {
        method: 'PUT',
        headers: {
            "Authorization": `Bearer ${matrix_res.token}`,
            "Content-Type": "application/json",
        },
        body: json_content,
    });
    if (!resp.ok) {
        throw Error(`Failed to read room state: Error HTTP${resp.status}`);
    }
    return await resp.json();
}
 Submitted by jaller94 1019 days ago
import * as wmill from "https://deno.land/x/windmill@v1.35.0/mod.ts";
export async function main(
  matrix_res: wmill.Resource<"matrix">,
  room_id: string,
  type: string,
  state_key: string,
  json_content: string,
) {
  let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/${encodeURIComponent(type)}/${encodeURIComponent(state_key)}`;
  const resp = await fetch(url, {
    method: 'PUT',
    headers: {
      "Authorization": `Bearer ${matrix_res.token}`,
      "Content-Type": "application/json",
    },
    body: json_content,
  });
  if (!resp.ok) {
    throw Error(`Failed to read room state: Error HTTP${resp.status}`);
  }
  return await resp.json();
}
 Submitted by jaller94 1019 days ago
import * as wmill from "https://deno.land/x/windmill@v1.35.0/mod.ts";
export async function main(
  matrix_res: wmill.Resource<"matrix">,
  room_id: string,
  type: string,
  state_key?: string,
  json_content: string,
) {
  let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/${encodeURIComponent(type)}/${encodeURIComponent(state_key)}`;
  const resp = await fetch(url, {
    method: 'PUT',
    headers: {
      "Authorization": `Bearer ${matrix_res.token}`,
      "Content-Type": "application/json",
    },
    body: json_content,
  });
  if (!resp.ok) {
    throw Error(`Failed to read room state: Error HTTP${resp.status}`);
  }
  return await resp.json();
}
 Submitted by jaller94 1019 days ago
import * as wmill from "https://deno.land/x/windmill@v1.35.0/mod.ts";
export async function main(
  matrix_res: wmill.Resource<"matrix">,
  room_id: string,
  type: string,
  state_key?: string,
  json_content: string,
) {
  let url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/${encodeURIComponent(type)}/`;
  if (state_key) {
    url += encodeURIComponent(state_key);
  }
  const resp = await fetch(url, {
    method: 'PUT',
    headers: {
      "Authorization": `Bearer ${matrix_res.token}`,
      "Content-Type": "application/json",
    },
    body: json_content,
  });
  if (!resp.ok) {
    throw Error(`Failed to read room state: Error HTTP${resp.status}`);
  }
  return await resp.json();
}
 Submitted by jaller94 1083 days ago