-
Notifications
You must be signed in to change notification settings - Fork 70
/
video-chat-archive.controller.ts
135 lines (130 loc) · 3.76 KB
/
video-chat-archive.controller.ts
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
// Copyright (c) 2023 Sourcefuse Technologies
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {inject} from '@loopback/core';
import {del, get, param, put, requestBody} from '@loopback/rest';
import {STRATEGY, authenticate} from 'loopback4-authentication';
import {authorize} from 'loopback4-authorization';
import {PermissionKeys} from '../enums/permission-keys.enum';
import {
CONTENT_TYPE,
OPERATION_SECURITY_SPEC,
STATUS_CODE,
} from '@sourceloop/core';
import {ExternalStorageOptions} from '..';
import {ServiceBindings} from '../keys';
import {ChatArchiveService} from '../services';
export class VideoChatArchiveController {
constructor(
@inject(ServiceBindings.ArchiveChatService)
public chatArchiveService: ChatArchiveService,
) {}
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKeys.GetArchives]})
@get('/archives/{archiveId}', {
description: `Used to fetch a specific archive w.r.t archiveId.
If archive is not present, it will throw HTTP Not Found Error.`,
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
content: {
[CONTENT_TYPE.JSON]: {
schema: {
type: 'object',
},
},
},
},
},
})
async getArchive(@param.path.string('archiveId') archiveId: string) {
return this.chatArchiveService.getArchive(archiveId);
}
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKeys.GetArchives]})
@get('/archives', {
description:
'Used to fetch a list of archives (meetings that were recorded).',
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
content: {
[CONTENT_TYPE.JSON]: {
schema: {
type: 'object',
},
},
},
},
},
})
async getArchives() {
return this.chatArchiveService.getArchives();
}
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKeys.DeleteArchive]})
@del('/archives/{archiveId}', {
description: `Used to delete a specific archive w.r.t archiveId.
If archive is not present, it will throw HTTP Not Found Error.`,
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
content: {
[CONTENT_TYPE.TEXT]: {
schema: {
type: 'text',
},
},
},
},
},
})
async deleteArchive(
@param.path.string('archiveId') archiveId: string,
): Promise<void> {
return this.chatArchiveService.deleteArchive(archiveId);
}
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKeys.SetUploadTarget]})
@put('/archives/storage-target', {
description:
'Configures custom storage target to a custom Amazon s3 bucket or Microsoft Azure Storage.',
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
content: {
[CONTENT_TYPE.TEXT]: {
schema: {
type: 'text',
},
},
},
},
},
})
async setUploadTarget(
@requestBody() body: ExternalStorageOptions,
): Promise<void> {
return this.chatArchiveService.setUploadTarget(body);
}
// TO-DO: will do modifications later
// @authenticate(STRATEGY.BEARER)
// @authorize({permissions:[PermissionKeys.SetUploadTarget]})
// @del('/archives/storage-target', {
// responses: {
// [STATUS_CODE.OK]: {
// content: {
// [CONTENT_TYPE.TEXT]: {
// schema: {
// type: 'text',
// },
// },
// },
// },
// },
// })
// async deleteCustomStorageTarget() {
// return this.videoChatProvider.deleteUploadTarget();
// }
}