|
@@ -9,14 +9,6 @@ from tracim.model.data import User
|
9
|
9
|
import uuid
|
10
|
10
|
|
11
|
11
|
|
12
|
|
-class JitsiMeetNoTokenGenerator(Exception):
|
13
|
|
- pass
|
14
|
|
-
|
15
|
|
-
|
16
|
|
-class JitsiMeetTokenNotActivated(Exception):
|
17
|
|
- pass
|
18
|
|
-
|
19
|
|
-
|
20
|
12
|
class JitsiMeetRoom(object):
|
21
|
13
|
def __init__(
|
22
|
14
|
self,
|
|
@@ -38,11 +30,19 @@ class JitsiMeetRoom(object):
|
38
|
30
|
)
|
39
|
31
|
self.room = self._generate_room_name(receivers)
|
40
|
32
|
|
41
|
|
- def _set_domain(self):
|
|
33
|
+ def _set_domain(self) -> None:
|
|
34
|
+ """
|
|
35
|
+ Set domain according to config
|
|
36
|
+ :return:
|
|
37
|
+ """
|
42
|
38
|
cfg = CFG.get_instance()
|
43
|
39
|
self.domain = cfg.JITSI_MEET_DOMAIN
|
44
|
40
|
|
45
|
|
- def _set_token_params(self):
|
|
41
|
+ def _set_token_params(self) -> None:
|
|
42
|
+ """
|
|
43
|
+ Set params related to token according to config.
|
|
44
|
+ :return: nothing
|
|
45
|
+ """
|
46
|
46
|
cfg = CFG.get_instance()
|
47
|
47
|
self.use_token = cfg.JITSI_MEET_USE_TOKEN
|
48
|
48
|
if self.use_token:
|
|
@@ -58,9 +58,18 @@ class JitsiMeetRoom(object):
|
58
|
58
|
self,
|
59
|
59
|
receivers: Workspace,
|
60
|
60
|
issuer: typing.Union[User, JitsiMeetUser, None],
|
61
|
|
- ):
|
|
61
|
+ ) -> None:
|
|
62
|
+ """
|
|
63
|
+ Set context of JWT token for Jitsi Meet
|
|
64
|
+ :param issuer: user who initiated Jitsi Meet talk
|
|
65
|
+ if None, default user is created. Can be both Tracim User or
|
|
66
|
+ JitsiMeetUser.
|
|
67
|
+ :param receivers: User or Room who can talk with sender. Now, only
|
|
68
|
+ Workspace are supported.
|
|
69
|
+ :return: nothing.
|
|
70
|
+ """
|
62
|
71
|
|
63
|
|
- # User
|
|
72
|
+ # INFO - G.M - 13-02-2018 - Convert all issuers values as JitsiMeetUser
|
64
|
73
|
if isinstance(issuer, JitsiMeetUser):
|
65
|
74
|
user = issuer
|
66
|
75
|
elif isinstance(issuer, User):
|
|
@@ -71,10 +80,11 @@ class JitsiMeetRoom(object):
|
71
|
80
|
)
|
72
|
81
|
else:
|
73
|
82
|
user = JitsiMeetUser(
|
|
83
|
+ # INFO - G.M - 13-02-2018 - create unique id for anonymous user
|
74
|
84
|
jitsi_meet_user_id=str(uuid.uuid4()),
|
75
|
85
|
)
|
76
|
86
|
|
77
|
|
- # Group
|
|
87
|
+ # INFO - G.M - 13-02-2018 - Associate
|
78
|
88
|
group = receivers.label
|
79
|
89
|
|
80
|
90
|
self.context = JitsiMeetContext(
|
|
@@ -83,7 +93,14 @@ class JitsiMeetRoom(object):
|
83
|
93
|
)
|
84
|
94
|
|
85
|
95
|
@classmethod
|
86
|
|
- def _generate_room_name(cls, workspace: Workspace):
|
|
96
|
+ def _generate_room_name(cls, workspace: Workspace) -> str:
|
|
97
|
+ """
|
|
98
|
+ Generate Jitsi-Meet room name related to workspace
|
|
99
|
+ that should be unique, always the same for same workspace in same Tracim
|
|
100
|
+ instance but should also no contains any special characters
|
|
101
|
+ :param workspace: Tracim Workspace
|
|
102
|
+ :return: room name as str.
|
|
103
|
+ """
|
87
|
104
|
cfg = CFG.get_instance()
|
88
|
105
|
room = "{uuid}{workspace_id}{workspace_label}".format(
|
89
|
106
|
uuid=cfg.TRACIM_INSTANCE_UUID,
|
|
@@ -94,6 +111,10 @@ class JitsiMeetRoom(object):
|
94
|
111
|
return str_as_alpha_num_str(room)
|
95
|
112
|
|
96
|
113
|
def generate_token(self) -> str:
|
|
114
|
+ """
|
|
115
|
+ Generate Jitsi-Meet related JWT token
|
|
116
|
+ :return: JWT token as str
|
|
117
|
+ """
|
97
|
118
|
if not self.use_token:
|
98
|
119
|
raise JitsiMeetTokenNotActivated
|
99
|
120
|
|
|
@@ -110,7 +131,7 @@ class JitsiMeetRoom(object):
|
110
|
131
|
|
111
|
132
|
def generate_url(self, token=None) -> str:
|
112
|
133
|
"""
|
113
|
|
- Generate url with or without token
|
|
134
|
+ Generate Jitsi-Meet url with or without token
|
114
|
135
|
:return: url as string
|
115
|
136
|
"""
|
116
|
137
|
if token:
|
|
@@ -122,3 +143,10 @@ class JitsiMeetRoom(object):
|
122
|
143
|
self.room,
|
123
|
144
|
)
|
124
|
145
|
return "https://{}".format(url)
|
|
146
|
+
|
|
147
|
+class JitsiMeetNoTokenGenerator(Exception):
|
|
148
|
+ pass
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+class JitsiMeetTokenNotActivated(Exception):
|
|
152
|
+ pass
|