1
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 179 days ago Viewed 365 times
0
Submitted by nextcloud Bun
Verified 10 days ago
1
import * as wmill from "windmill-client";
2
import createClient, { type Middleware } from "openapi-fetch";
3

4
type Nextcloud = {
5
  baseUrl: string,
6
  password: string,
7
  username: string
8
};
9

10
export async function main(
11
  ncResource: Nextcloud,
12

13
  userId: string | null = null,
14

15
  useAppApiAuth: boolean = false,
16
) {
17

18
  const client = createClient<paths>({ baseUrl: ncResource.baseUrl });
19
  const authMiddleware: Middleware = {
20
    async onRequest({ request, options }) {
21
      // fetch token, if it doesn’t exist
22
      // add Authorization header to every request
23
      request.headers.set("Authorization", `Basic ${btoa((userId || ncResource.username) + ':' + ncResource.password)}`);
24
      if (useAppApiAuth) {
25
        request.headers.set("AA-VERSION", "2.3.0",);
26
        request.headers.set("EX-APP-ID", "flow",);
27
        request.headers.set("EX-APP-VERSION", "1.0.1",);
28
        request.headers.set("AUTHORIZATION-APP-API", btoa(
29
          `${userId || ncResource.username}:${ncResource.password}`,
30
        ));
31
      }
32
      return request;
33
    },
34
  };
35
  client.use(authMiddleware);
36

37
  const res = await client.GET("/ocs/v2.php/apps/spreed/api/{apiVersion}/room", {
38
    params: {
39
      header: {
40
        "OCS-APIRequest": true,
41
      },
42
      query: {
43
        format: "json",
44
      },
45
      path: {
46
        apiVersion: "v4",
47
      },
48

49
    },
50
  });
51

52
  return await res.data;
53

54
}
Other submissions