Browse Source

tracim cfg as attribute

Guénaël Muller 6 years ago
parent
commit
2280fb0c99
1 changed files with 12 additions and 14 deletions
  1. 12 14
      tracim/tracim/lib/jitsi_meet/room.py

+ 12 - 14
tracim/tracim/lib/jitsi_meet/room.py View File

22
         :param receivers: User or Room who can talk with sender. Now, only
22
         :param receivers: User or Room who can talk with sender. Now, only
23
         Workspace are supported.
23
         Workspace are supported.
24
         """
24
         """
25
+        self.tracim_cfg = CFG.get_instance()
25
         self._set_domain()
26
         self._set_domain()
26
         self._set_token_params()
27
         self._set_token_params()
27
         self._set_context(
28
         self._set_context(
35
         Set domain according to config
36
         Set domain according to config
36
         :return:
37
         :return:
37
         """
38
         """
38
-        cfg = CFG.get_instance()
39
-        self.domain = cfg.JITSI_MEET_DOMAIN
39
+        self.domain = self.tracim_cfg.JITSI_MEET_DOMAIN
40
 
40
 
41
     def _set_token_params(self) -> None:
41
     def _set_token_params(self) -> None:
42
         """
42
         """
43
         Set params related to token according to config.
43
         Set params related to token according to config.
44
         :return: nothing
44
         :return: nothing
45
         """
45
         """
46
-        cfg = CFG.get_instance()
47
-        self.use_token = cfg.JITSI_MEET_USE_TOKEN
46
+        self.use_token = self.tracim_cfg.JITSI_MEET_USE_TOKEN
48
         if self.use_token:
47
         if self.use_token:
49
-            if cfg.JITSI_MEET_TOKEN_GENERATOR == 'local':
50
-                self.token_app_id = cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_APP_ID  # nopep8
51
-                self.token_secret = cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_SECRET  # nopep8
52
-                self.token_alg = cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_ALG
53
-                self.token_duration = cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_DURATION  # nopep8
48
+            if self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR == 'local':
49
+                self.token_app_id = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_APP_ID  # nopep8
50
+                self.token_secret = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_SECRET  # nopep8
51
+                self.token_alg = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_ALG   # nopep8
52
+                self.token_duration = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_DURATION  # nopep8
54
             else:
53
             else:
55
                 raise JitsiMeetNoTokenGenerator
54
                 raise JitsiMeetNoTokenGenerator
56
 
55
 
92
             group=group,
91
             group=group,
93
         )
92
         )
94
 
93
 
95
-    @classmethod
96
-    def _generate_room_name(cls, workspace: Workspace) -> str:
94
+    def _generate_room_name(self, workspace: Workspace) -> str:
97
         """
95
         """
98
         Generate Jitsi-Meet room name related to workspace
96
         Generate Jitsi-Meet room name related to workspace
99
         that should be unique, always the same for same workspace in same Tracim
97
         that should be unique, always the same for same workspace in same Tracim
101
         :param workspace: Tracim Workspace
99
         :param workspace: Tracim Workspace
102
         :return: room name as str.
100
         :return: room name as str.
103
         """
101
         """
104
-        cfg = CFG.get_instance()
105
         room = "{uuid}{workspace_id}{workspace_label}".format(
102
         room = "{uuid}{workspace_id}{workspace_label}".format(
106
-            uuid=cfg.TRACIM_INSTANCE_UUID,
103
+            uuid=self.tracim_cfg.TRACIM_INSTANCE_UUID,
107
             workspace_id=workspace.workspace_id,
104
             workspace_id=workspace.workspace_id,
108
             workspace_label=workspace.label)
105
             workspace_label=workspace.label)
109
 
106
 
144
                                  )
141
                                  )
145
         return "https://{}".format(url)
142
         return "https://{}".format(url)
146
 
143
 
144
+
147
 class JitsiMeetNoTokenGenerator(Exception):
145
 class JitsiMeetNoTokenGenerator(Exception):
148
     pass
146
     pass
149
 
147
 
150
 
148
 
151
 class JitsiMeetTokenNotActivated(Exception):
149
 class JitsiMeetTokenNotActivated(Exception):
152
-    pass
150
+    pass