Quellcode durchsuchen

tracim cfg as attribute

Guénaël Muller vor 6 Jahren
Ursprung
Commit
2280fb0c99
1 geänderte Dateien mit 12 neuen und 14 gelöschten Zeilen
  1. 12 14
      tracim/tracim/lib/jitsi_meet/room.py

+ 12 - 14
tracim/tracim/lib/jitsi_meet/room.py Datei anzeigen

@@ -22,6 +22,7 @@ class JitsiMeetRoom(object):
22 22
         :param receivers: User or Room who can talk with sender. Now, only
23 23
         Workspace are supported.
24 24
         """
25
+        self.tracim_cfg = CFG.get_instance()
25 26
         self._set_domain()
26 27
         self._set_token_params()
27 28
         self._set_context(
@@ -35,22 +36,20 @@ class JitsiMeetRoom(object):
35 36
         Set domain according to config
36 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 41
     def _set_token_params(self) -> None:
42 42
         """
43 43
         Set params related to token according to config.
44 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 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 53
             else:
55 54
                 raise JitsiMeetNoTokenGenerator
56 55
 
@@ -92,8 +91,7 @@ class JitsiMeetRoom(object):
92 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 96
         Generate Jitsi-Meet room name related to workspace
99 97
         that should be unique, always the same for same workspace in same Tracim
@@ -101,9 +99,8 @@ class JitsiMeetRoom(object):
101 99
         :param workspace: Tracim Workspace
102 100
         :return: room name as str.
103 101
         """
104
-        cfg = CFG.get_instance()
105 102
         room = "{uuid}{workspace_id}{workspace_label}".format(
106
-            uuid=cfg.TRACIM_INSTANCE_UUID,
103
+            uuid=self.tracim_cfg.TRACIM_INSTANCE_UUID,
107 104
             workspace_id=workspace.workspace_id,
108 105
             workspace_label=workspace.label)
109 106
 
@@ -144,9 +141,10 @@ class JitsiMeetRoom(object):
144 141
                                  )
145 142
         return "https://{}".format(url)
146 143
 
144
+
147 145
 class JitsiMeetNoTokenGenerator(Exception):
148 146
     pass
149 147
 
150 148
 
151 149
 class JitsiMeetTokenNotActivated(Exception):
152
-    pass
150
+    pass