Browse Source

Better room naming : UUID + str convert method in utils

Guénaël Muller 6 years ago
parent
commit
e2a83bcbfe
2 changed files with 21 additions and 5 deletions
  1. 8 5
      tracim/tracim/controllers/jitsi_meet.py
  2. 13 0
      tracim/tracim/lib/utils.py

+ 8 - 5
tracim/tracim/controllers/jitsi_meet.py View File

6
 from tracim.lib.predicates import current_user_is_reader
6
 from tracim.lib.predicates import current_user_is_reader
7
 from sqlalchemy.orm.exc import NoResultFound
7
 from sqlalchemy.orm.exc import NoResultFound
8
 
8
 
9
-from unidecode import unidecode
9
+from tracim.lib.utils import str_as_alpha_num_str
10
 from tracim.lib.jitsi_meet.jitsi_meet import JitsiMeetRoom
10
 from tracim.lib.jitsi_meet.jitsi_meet import JitsiMeetRoom
11
 from tracim.lib.jitsi_meet.jitsi_meet import JitsiTokenConfig
11
 from tracim.lib.jitsi_meet.jitsi_meet import JitsiTokenConfig
12
 from tracim.config.app_cfg import CFG
12
 from tracim.config.app_cfg import CFG
41
         dictified_workspace = Context(CTX.WORKSPACE).toDict(workspace,
41
         dictified_workspace = Context(CTX.WORKSPACE).toDict(workspace,
42
                                                             'workspace')
42
                                                             'workspace')
43
 
43
 
44
-        label = unidecode(workspace.label)
45
-        parsed_label = ''.join(e for e in label if e.isalnum())
46
         # TODO - G.M - 18-01-2017 -
44
         # TODO - G.M - 18-01-2017 -
47
         # allow to set specific room name from workspace object ?
45
         # allow to set specific room name from workspace object ?
48
-        room = "{id}{label}".format(id=workspace.workspace_id,
49
-                                    label=parsed_label)
46
+        room = "{uuid}{workspace_id}{workspace_label}".format(
47
+            uuid=cfg.TRACIM_INSTANCE_UUID,
48
+            workspace_id=workspace.workspace_id,
49
+            workspace_label=workspace.label)
50
+
51
+        # Jitsi-Meet doesn't like specials_characters
52
+        room = str_as_alpha_num_str(room)
50
 
53
 
51
         token = None
54
         token = None
52
         if cfg.JITSI_MEET_USE_TOKEN:
55
         if cfg.JITSI_MEET_USE_TOKEN:

+ 13 - 0
tracim/tracim/lib/utils.py View File

16
 from tg.util import lazify
16
 from tg.util import lazify
17
 from redis import Redis
17
 from redis import Redis
18
 from rq import Queue
18
 from rq import Queue
19
+from unidecode import unidecode
19
 
20
 
20
 from tracim.lib.base import logger
21
 from tracim.lib.base import logger
21
 from webob import Response
22
 from webob import Response
140
     return bool(string)
141
     return bool(string)
141
 
142
 
142
 
143
 
144
+def str_as_alpha_num_str(unicode_string: str) -> str:
145
+    """
146
+    convert unicode string to alpha_num-only string.
147
+    convert also accented character to ascii equivalent.
148
+    :param unicode_string:
149
+    :return:
150
+    """
151
+    ascii_string = unidecode(unicode_string)
152
+    alpha_num_string = ''.join(e for e in ascii_string if e.isalnum())
153
+    return alpha_num_string
154
+
155
+
143
 class LazyString(BaseLazyString):
156
 class LazyString(BaseLazyString):
144
     pass
157
     pass
145
 
158