Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit af94d54

Browse files
committed
chore: add v4 presences endpoint to fix iFrameRegExp
1 parent 87e74b9 commit af94d54

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { gql } from "apollo-server-core";
2+
3+
import Presences from "../../v3/fields/presences";
4+
5+
interface PresenceQueryArgs {
6+
service?: string | string[];
7+
author?: string;
8+
contributor?: string;
9+
start?: number;
10+
limit?: number;
11+
query?: string;
12+
tag?: string;
13+
}
14+
15+
export const schema = gql`
16+
type Query {
17+
presences(
18+
service: StringOrStringArray
19+
author: String
20+
contributor: String
21+
start: Int
22+
limit: Int
23+
query: String
24+
tag: String
25+
): [Presence!]!
26+
}
27+
28+
type Presence {
29+
url: String!
30+
metadata: PresenceMetadata!
31+
presenceJs: String!
32+
iframeJs: String
33+
users: Int!
34+
}
35+
36+
type PresenceMetadata {
37+
author: PresenceMetadataUser!
38+
contributors: [PresenceMetadataUser!]
39+
altnames: [String!]
40+
service: String!
41+
description: Scalar! # serialize
42+
url: Scalar! # serialize
43+
version: String!
44+
logo: String!
45+
thumbnail: String!
46+
color: String!
47+
tags: [String!]!
48+
category: String!
49+
iframe: Boolean
50+
regExp: String
51+
iFrameRegExp: String
52+
readLogs: Boolean
53+
button: Boolean
54+
warning: Boolean
55+
settings: [PresenceMetadataSettings!]
56+
}
57+
58+
type PresenceMetadataUser {
59+
id: String!
60+
name: String!
61+
}
62+
63+
type PresenceMetadataSettings {
64+
id: String!
65+
title: String
66+
icon: String
67+
if: PresenceMetadataSettingsIf # serialize
68+
placeholder: String
69+
value: Scalar # serialize
70+
values: Scalar # serialize
71+
multiLanguage: Scalar # serialize
72+
}
73+
74+
type PresenceMetadataSettingsIf {
75+
propertyNames: String
76+
patternProperties: Scalar
77+
}
78+
`;
79+
80+
export async function resolver(
81+
_: any,
82+
args: PresenceQueryArgs,
83+
{ dataSources: { presences } }: { dataSources: { presences: Presences } }
84+
) {
85+
if (!Object.keys(args).length) return presences.getAll();
86+
87+
return presences.get(args);
88+
}

0 commit comments

Comments
 (0)