Edits history of script submission #104 for ' Invite user to a room (matrix)'

  • deno
    type Matrix = {
      baseUrl: string;
      token: string;
    };
    export async function main(
      matrix_res: Matrix,
      room_id: string,
      user_id: string,
      reason = "",
    ) {
      if (!matrix_res.token) {
        throw Error("Inviting a user requires an access token.");
      }
      const resp = await fetch(
        `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(
          room_id,
        )}/invite`,
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${matrix_res.token}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            user_id,
            ...(reason && { reason }),
          }),
        },
      );
      if (!resp.ok) {
        throw Error(`Failed to invite: Error HTTP${resp.status}`);
      }
    }
    

    Submitted by hugo697 396 days ago

  • deno
    type Matrix = {
      baseUrl: string;
      token: string;
    };
    export async function main(
      matrix_res: Matrix,
      room_id: string,
      user_id: string,
      reason = "",
    ) {
      if (!matrix_res.token) {
        throw Error("Inviting a user requires an access token.");
      }
      const resp = await fetch(
        `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(
          room_id,
        )}/invite`,
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${matrix_res.token}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            user_id,
            ...(reason && { reason }),
          }),
        },
      );
      if (!resp.ok) {
        throw Error(`Failed to invite: Error HTTP${resp.status}`);
      }
    }
    

    Submitted by admin 1028 days ago

  • deno
    
    type Matrix = {
      baseUrl: string;
      token: string;
    };
    export async function main(
    	matrix_res: Matrix,
    	room_id: string,
        user_id: string,
        reason = "",
    ) {
    	if (!matrix_res.token) {
    		throw Error("Inviting a user requires an access token.");
    	}
    	const resp = await fetch(
    		`${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/invite`,
    		{
    			method: "POST",
    			headers: {
    				"Authorization": `Bearer ${matrix_res.token}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    user_id,
                    ...(reason && {reason}),
                }),
    		},
    	);
    	if (!resp.ok) {
    		throw Error(`Failed to invite: Error HTTP${resp.status}`);
    	}
    }
    

    Submitted by admin 1031 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
    	matrix_res: wmill.Resource<"matrix">,
    	room_id: string,
        user_id: string,
        reason = "",
    ) {
    	if (!matrix_res.token) {
    		throw Error("Inviting a user requires an access token.");
    	}
    	const resp = await fetch(
    		`${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/invite`,
    		{
    			method: "POST",
    			headers: {
    				"Authorization": `Bearer ${matrix_res.token}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    user_id,
                    ...(reason && {reason}),
                }),
    		},
    	);
    	if (!resp.ok) {
    		throw Error(`Failed to invite: Error HTTP${resp.status}`);
    	}
    }
    

    Submitted by adam186 1160 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
    	matrix_res: wmill.Resource<"matrix">,
    	room_id: string,
        user_id: string,
        reason = "",
    ) {
    	if (!matrix_res.token) {
    		throw Error("Inviting a user requires an access token.");
    	}
    	const resp = await fetch(
    		`${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/invite`,
    		{
    			method: "POST",
    			headers: {
    				"Authorization": `Bearer ${matrix_res.token}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    user_id,
                    ...(reason && {reason}),
                }),
    		},
    	);
    	if (!resp.ok) {
    		throw Error(`Failed to invite: Error HTTP${resp.status}`);
    	}
    }
    

    Submitted by adam186 1195 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
    	matrix_res: wmill.Resource<"matrix">,
    	room_id: string,
        user_id: string,
        reason = "",
    ) {
    	if (!matrix_res.token) {
    		throw Error("Inviting a user requires an access token.");
    	}
    	const resp = await fetch(
    		`${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/invite`,
    		{
    			method: "POST",
    			headers: {
    				"Authorization": `Bearer ${matrix_res.token}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    user_id,
                    ...(reason && {reason}),
                }),
    		},
    	);
    	if (!resp.ok) {
    		throw Error(`Failed to invite: Error HTTP${resp.status}`);
    	}
    }
    

    Submitted by jaller94 1344 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
    	matrix_res: wmill.Resource<"matrix">,
    	room_id: string,
        user_id: string,
        reason = "",
    ) {
    	if (!matrix_res.accessToken) {
    		throw Error("Inviting a user requires an access token.");
    	}
    	const resp = await fetch(
    		`${matrix_res.homeserverUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/invite`,
    		{
    			method: "POST",
    			headers: {
    				"Authorization": `Bearer ${matrix_res.accessToken}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    user_id,
                    ...(reason && {reason}),
                }),
    		},
    	);
    	if (!resp.ok) {
    		throw Error(`Failed to invite: Error HTTP${resp.status}`);
    	}
    }
    

    Submitted by jaller94 1395 days ago

  • deno
    
    
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
    	matrix_res: wmill.Resource<"matrix">,
    	room_id: string,
        user_id: string,
        reason = "",
    ) {
    	if (!matrix_res.accessToken) {
    		throw Error("Inviting a user requires an access token.");
    	}
    	const resp = await fetch(
    		`${matrix_res.homeserverUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/invite`,
    		{
    			method: "POST",
    			headers: {
    				"Authorization": `Bearer ${matrix_res.accessToken}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    user_id,
                    ...(reason && {reason}),
                }),
    		},
    	);
    	if (!resp.ok) {
    		throw Error(`Failed to join room: Error HTTP${resp.status}`);
    	}
    }
    

    Submitted by jaller94 1395 days ago