-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
444 lines (432 loc) · 15.4 KB
/
openapi.yaml
File metadata and controls
444 lines (432 loc) · 15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
openapi: 3.0.0
info:
title: matrix2acrobits
version: 1.0.0
description: API proxy to adapt Acrobits Cloud Softphone to Matrix.
servers:
- url: http://localhost:8080
description: Local development server
paths:
/api/client/fetch_messages:
post:
summary: Fetch Messages
operationId: fetchMessages
description: |
Checks for new incoming messages by performing a Matrix /sync on behalf of the user.
Authentication is performed against an external authentication service (2-step flow):
1. POST /api/login with username and password to get JWT token
2. GET /api/chat?users=1 with Bearer token to fetch user mappings and verify chat capability
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- username
- password
properties:
username:
type: string
description: The extension/username (format can be user@domain), which is sent to the external auth service.
password:
type: string
description: Password used to authenticate via the external auth service.
last_id:
type: string
description: The 'since' token from the last sync.
last_sent_id:
type: string
description: The message id of the last sent message.
device:
type: string
description: Device identifier (e.g., 'ACROBITS').
responses:
'200':
description: Successful sync
content:
application/json:
schema:
$ref: '#/components/schemas/FetchMessagesResponse'
'401':
description: Authentication failed (e.g., user not in AS namespace).
/api/client/send_message:
post:
summary: Send Message
operationId: sendMessage
description: |
Sends an outgoing message on behalf of a user.
The `from` field can be:
- A full Matrix ID (e.g., @user:server.com) - used directly
- A phone number (e.g., +1234567890) - resolved to Matrix ID via phone-to-Matrix mapping if available
If a phone number is provided and a mapping exists, the message is sent on behalf of the mapped Matrix user.
If a phone number is provided but no mapping exists, the phone number is used as the sender ID.
Authentication is performed against an external authentication service (2-step flow):
1. POST /api/login with username and password to get JWT token
2. GET /api/chat?users=1 with Bearer token to fetch user mappings and verify chat capability
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- from
- to
- body
- password
properties:
from:
type: string
description: The sender - either a full Matrix ID (e.g., @user:server.com) or a phone number (e.g., +1234567890).
password:
type: string
description: Password used to authenticate the sender via the external auth service.
to:
type: string
description: Recipient Matrix ID, Alias, or mapped phone number.
body:
type: string
description: The message content.
content_type:
type: string
default: text/plain
disposition_notification:
type: string
description: Opaque string for read receipts.
responses:
'200':
description: Message sent successfully
content:
application/json:
schema:
type: object
properties:
message_id:
type: string
description: The Matrix event ID of the sent message.
'400':
description: Invalid request or recipient.
'401':
description: Authentication failed (e.g., user not in AS namespace).
/api/client/push_token_report:
post:
summary: Report Push Token
operationId: pushTokenReport
description: |
Receives and stores device push tokens from Acrobits clients.
The tokens are persisted in a SQLite database for later use in push notification delivery.
This endpoint follows the Acrobits Push Token Reporter API specification for POST JSON requests.
Authentication is performed against an external authentication service (2-step flow):
1. POST /api/login with username and password to get JWT token
2. GET /api/chat?users=1 with Bearer token to fetch user mappings and verify chat capability
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PushTokenReportRequest'
responses:
'200':
description: Push token accepted and stored
content:
application/json:
schema:
type: object
description: Empty JSON object response
'400':
description: Invalid request payload (e.g., missing selector).
'500':
description: Server error (e.g., database unavailable).
example:
request:
selector: "12869E0E6E553673C54F29105A0647204C416A2A:7C3A0D14"
token_msgs: "QVBBOTFiRzlhcVd2bW54bllCWldHOWh4dnRrZ3pUWFNvcGZpdWZ6bWM2dFAzS2J"
appid_msgs: "com.cloudsoftphone.app"
token_calls: "Udl99X2JFP1bWwS5gR/wGeLE1hmAB2CMpr1Ej0wxkrY="
appid_calls: "com.cloudsoftphone.app.pushkit"
response:
{}
/api/internal/push_tokens:
get:
summary: Get all push tokens
description: |
Returns the contents of the push token database. Requires the `X-Super-Admin-Token` header
and can only be accessed from localhost.
parameters:
- in: header
name: X-Super-Admin-Token
schema:
type: string
required: true
description: The Application Service token (as_token).
responses:
'200':
description: Push tokens retrieved successfully
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PushToken'
'401':
description: Invalid admin token.
'403':
description: Access denied (not from localhost).
'500':
description: Server error (e.g., database unavailable).
delete:
summary: Reset push token database
description: |
Deletes all push tokens from the database. Requires the `X-Super-Admin-Token` header
and can only be accessed from localhost.
parameters:
- in: header
name: X-Super-Admin-Token
schema:
type: string
required: true
description: The Application Service token (as_token).
responses:
'200':
description: Push tokens database reset successfully
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: "reset"
'401':
description: Invalid admin token.
'403':
description: Access denied (not from localhost).
'500':
description: Server error (e.g., database unavailable).
/_matrix/push/v1/notify:
post:
summary: Matrix Push Gateway Notify
operationId: matrixPushNotify
description: |
Endpoint used by a Matrix homeserver (push gateway) to deliver push notifications
to this proxy. The proxy will translate Matrix notifications into Acrobits PNM
requests and return any rejected pushkeys in the response.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MatrixPushNotifyRequest'
responses:
'200':
description: Notification processed successfully
content:
application/json:
schema:
$ref: '#/components/schemas/MatrixPushNotifyResponse'
'400':
description: Invalid request payload
'500':
description: Server error while processing notification
/_matrix/app/v1/transactions/{txnId}:
put:
summary: Application Service Transaction
description: |
Endpoint used by a Matrix homeserver to deliver application-service transactions
(batches of events) to the Application Service. The proxy accepts the payload,
logs it for debugging and acknowledges with 200 OK.
parameters:
- in: path
name: txnId
required: true
schema:
type: string
description: Transaction id assigned by the homeserver
requestBody:
required: true
content:
application/json:
schema:
type: object
description: Application Service transaction payload (events array and other fields)
additionalProperties: true
responses:
'200':
description: Transaction received and acknowledged
'400':
description: Invalid payload
components:
schemas:
SMS:
type: object
description: A message following the Acrobits Modern API format.
properties:
sms_id:
type: string
description: Unique identifier (Matrix Event ID).
sending_date:
type: string
format: date-time
description: RFC 3339 timestamp when the message was sent.
sender:
type: string
description: Sender identifier (phone number or user name). Only present in received messages.
recipient:
type: string
description: Recipient identifier (phone number or user name). Only present in sent messages.
sms_text:
type: string
description: Message body (UTF-8 encoded).
content_type:
type: string
description: MIME content-type. Defaults to text/plain if omitted.
disposition_notification:
type: string
description: Opaque string from Send Message request. Can be omitted if empty.
displayed:
type: boolean
description: True if message has already been displayed on another device. Only in received messages.
stream_id:
type: string
description: Identifier for the conversation stream (Room ID or identifier).
FetchMessagesResponse:
type: object
description: Response from the fetch_messages endpoint following Acrobits Modern API specification.
properties:
date:
type: string
format: date-time
description: Current server time in RFC 3339 format (used to synchronize timestamps).
received_smss:
type: array
items:
$ref: '#/components/schemas/SMS'
description: Array of received messages. Sorted by sending_date in ascending order (oldest first).
sent_smss:
type: array
items:
$ref: '#/components/schemas/SMS'
description: Array of sent messages. Sorted by sending_date in ascending order (oldest first).
MatrixPushNotifyRequest:
type: object
properties:
notification:
$ref: '#/components/schemas/MatrixNotification'
MatrixNotification:
type: object
properties:
event_id:
type: string
room_id:
type: string
type:
type: string
sender:
type: string
sender_display_name:
type: string
content:
type: object
additionalProperties: true
counts:
$ref: '#/components/schemas/MatrixCounts'
devices:
type: array
items:
$ref: '#/components/schemas/MatrixDevice'
MatrixCounts:
type: object
properties:
unread:
type: integer
missed_calls:
type: integer
MatrixDevice:
type: object
properties:
app_id:
type: string
pushkey:
type: string
pushkey_ts:
type: integer
tweaks:
type: object
additionalProperties: true
MatrixPushNotifyResponse:
type: object
properties:
rejected:
type: array
items:
type: string
PushTokenReportRequest:
type: object
required:
- selector
- password
properties:
username:
type: string
description: The extension or selector username reporting the token.
password:
type: string
description: Password used to authenticate the extension via the external auth service.
selector:
type: string
description: |
SHA1 hash with suffix that uniquely identifies the account.
Used to reference the account in push notification delivery requests.
Example: 12869E0E6E553673C54F29105A0647204C416A2A:7C3A0D14
token_msgs:
type: string
description: |
Base64-encoded push token for regular notifications (APNs remote-notification).
Required for iOS push notifications.
appid_msgs:
type: string
description: |
Apple application ID for regular notifications.
Used in conjunction with token_msgs.
token_calls:
type: string
description: |
Base64-encoded push token for VoIP/incoming call notifications (APNs pushkit).
Required for iOS incoming call notifications.
appid_calls:
type: string
description: |
Apple application ID for incoming call notifications.
Used in conjunction with token_calls.
PushToken:
type: object
properties:
id:
type: integer
description: Internal database ID.
selector:
type: string
description: |
SHA1 hash with suffix that uniquely identifies the account.
Example: 12869E0E6E553673C54F29105A0647204C416A2A:7C3A0D14
token_msgs:
type: string
description: Base64-encoded push token for regular notifications.
appid_msgs:
type: string
description: Apple application ID for regular notifications.
token_calls:
type: string
description: Base64-encoded push token for VoIP/incoming call notifications.
appid_calls:
type: string
description: Apple application ID for incoming call notifications.
created_at:
type: string
format: date-time
description: Timestamp when the push token was first created (RFC 3339).
updated_at:
type: string
format: date-time
description: Timestamp when the push token was last updated (RFC 3339).