Edits history of script submission #286 for ' Set room name (matrix)'

  • deno
    /**
     * Set the name of a Matrix room.
     *
     * HTTP endpoint: https://spec.matrix.org/v1.5/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
     *
     * State event description: https://spec.matrix.org/v1.5/client-server-api/#mroomname
     */
    type Matrix = {
      baseUrl: string;
      token: string;
    };
    export async function main(
      matrix_res: Matrix,
      room_id: string,
      name: string = "",
    ) {
      const url = `${
        matrix_res.baseUrl
      }/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/m.room.name/`;
      const resp = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: `Bearer ${matrix_res.token}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          name,
        }),
      });
      if (!resp.ok) {
        throw Error(`Failed to set room name: Error HTTP${resp.status}`);
      }
      return await resp.json();
    }
    

    Submitted by hugo697 398 days ago

  • deno
    /**
     * Set the name of a Matrix room.
     *
     * HTTP endpoint: https://spec.matrix.org/v1.5/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
     *
     * State event description: https://spec.matrix.org/v1.5/client-server-api/#mroomname
     */
    type Matrix = {
      baseUrl: string;
      token: string;
    };
    export async function main(
      matrix_res: Matrix,
      room_id: string,
      name: string = "",
    ) {
      const url = `${
        matrix_res.baseUrl
      }/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/m.room.name/`;
      const resp = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: `Bearer ${matrix_res.token}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          name,
        }),
      });
      if (!resp.ok) {
        throw Error(`Failed to set room name: Error HTTP${resp.status}`);
      }
      return await resp.json();
    }
    

    Submitted by admin 1031 days ago

  • deno
    
    /**
     * Set the name of a Matrix room.
     *
     * HTTP endpoint: https://spec.matrix.org/v1.5/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
     *
     * State event description: https://spec.matrix.org/v1.5/client-server-api/#mroomname
     */
    type Matrix = {
      baseUrl: string;
      token: string;
    };
    export async function main(
        matrix_res: Matrix,
        room_id: string,
        name: string = "",
    ) {
        const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/m.room.name/`;
        const resp = await fetch(url, {
            method: 'PUT',
            headers: {
                "Authorization": `Bearer ${matrix_res.token}`,
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                name,
            }),
        });
        if (!resp.ok) {
            throw Error(`Failed to set room name: Error HTTP${resp.status}`);
        }
        return await resp.json();
    }

    Submitted by admin 1034 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Set the name of a Matrix room.
     *
     * HTTP endpoint: https://spec.matrix.org/v1.5/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
     *
     * State event description: https://spec.matrix.org/v1.5/client-server-api/#mroomname
     */
    export async function main(
        matrix_res: wmill.Resource<"matrix">,
        room_id: string,
        name: string = "",
    ) {
        const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/m.room.name/`;
        const resp = await fetch(url, {
            method: 'PUT',
            headers: {
                "Authorization": `Bearer ${matrix_res.token}`,
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                name,
            }),
        });
        if (!resp.ok) {
            throw Error(`Failed to set room name: Error HTTP${resp.status}`);
        }
        return await resp.json();
    }

    Submitted by adam186 1162 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Set the name of a Matrix room.
     *
     * HTTP endpoint: https://spec.matrix.org/v1.5/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
     *
     * State event description: https://spec.matrix.org/v1.5/client-server-api/#mroomname
     */
    export async function main(
        matrix_res: wmill.Resource<"matrix">,
        room_id: string,
        name: string = "",
    ) {
        const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/m.room.name/`;
        const resp = await fetch(url, {
            method: 'PUT',
            headers: {
                "Authorization": `Bearer ${matrix_res.token}`,
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                name,
            }),
        });
        if (!resp.ok) {
            throw Error(`Failed to set room name: Error HTTP${resp.status}`);
        }
        return await resp.json();
    }

    Submitted by adam186 1197 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Set the name of a Matrix room.
     *
     * HTTP endpoint: https://spec.matrix.org/v1.5/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
     *
     * State event description: https://spec.matrix.org/v1.5/client-server-api/#mroomname
     */
    export async function main(
        matrix_res: wmill.Resource<"matrix">,
        room_id: string,
        name: string = "",
    ) {
        const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/m.room.name/`;
        const resp = await fetch(url, {
            method: 'PUT',
            headers: {
                "Authorization": `Bearer ${matrix_res.token}`,
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                name,
            }),
        });
        if (!resp.ok) {
            throw Error(`Failed to set room name: Error HTTP${resp.status}`);
        }
        return await resp.json();
    }

    Submitted by jaller94 1236 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Set the name of a Matrix room.
     *
     * HTTP endpoint: https://spec.matrix.org/v1.5/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
     *
     * State event description: https://spec.matrix.org/v1.5/client-server-api/#mroomname
     */
    export async function main(
        matrix_res: wmill.Resource<"matrix">,
        room_id: string,
        name: string = "",
    ) {
        const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state/m.room.name/`;
        const resp = await fetch(url, {
            method: 'PUT',
            headers: {
                "Authorization": `Bearer ${matrix_res.token}`,
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                name,
            }),
        });
        if (!resp.ok) {
            throw Error(`Failed to read room state: Error HTTP${resp.status}`);
        }
        return await resp.json();
    }

    Submitted by jaller94 1236 days ago