Nextcloud Talk: List all rooms
One script reply has been approved by the moderators Verified

List all talk rooms that a user has access to.

Created by marcel klehr12 595 days ago Picked 3 times
Submitted by nextcloud Bun
Verified 21 days ago
1
import createClient, { type Middleware } from "openapi-fetch";
2

3
export async function main(
4
  nextcloud: RT.Nextcloud,
5
) {
6

7
  const client = createClient<paths>({ baseUrl: nextcloud.baseUrl });
8
  const authMiddleware: Middleware = {
9
    async onRequest({ request, options }) {
10
      // fetch token, if it doesn’t exist
11
      // add Authorization header to every request
12
      request.headers.set("Authorization", `Basic ${btoa((nextcloud.userId) + ':' + nextcloud.token)}`);
13
      return request;
14
    },
15
  };
16
  client.use(authMiddleware);
17

18
  const res = await client.GET("/ocs/v2.php/apps/spreed/api/{apiVersion}/room", {
19
    params: {
20
      header: {
21
        "OCS-APIRequest": true,
22
      },
23
      query: {
24
        format: "json",
25
      },
26
      path: {
27
        apiVersion: "v4",
28
      },
29

30
    },
31
  });
32

33
  return await res.data;
34

35
}
Other submissions