Kaynağa Gözat

allow custom roomnode function as part of config to make deployment changes easier to merge

j8
Philipp Hancke 11 yıl önce
ebeveyn
işleme
9ceb0799ed
2 değiştirilmiş dosya ile 21 ekleme ve 12 silme
  1. 20
    12
      app.js
  2. 1
    0
      config.js

+ 20
- 12
app.js Dosyayı Görüntüle

@@ -48,19 +48,27 @@ function doJoin() {
48 48
     var roomnode = null;
49 49
     var path = window.location.pathname;
50 50
     var roomjid;
51
-    /*
52
-     * this is making assumptions about how the URL->room mapping happens.
53
-     * It currently assumes deployment at root, with a rewrite like the
54
-     * following one (for nginx):
55
-    location ~ ^/([a-zA-Z0-9]+)$ {
56
-        rewrite ^/(.*)$ / break;
57
-    }
58
-     */
59
-    if (path.length > 1) {
60
-        roomnode = path.substr(1).toLowerCase();
51
+
52
+    // determinde the room node from the url
53
+    // TODO: just the roomnode or the whole bare jid?
54
+    if (config.getroomnode && typeof config.getroomnode === 'function') {
55
+        // custom function might be responsible for doing the pushstate
56
+        roomnode = config.getroomnode(path);
61 57
     } else {
62
-        roomnode = Math.random().toString(36).substr(2, 20);
63
-        window.history.pushState('VideoChat', 'Room: ' + roomnode, window.location.pathname + roomnode);
58
+        /* fall back to default strategy
59
+         * this is making assumptions about how the URL->room mapping happens.
60
+         * It currently assumes deployment at root, with a rewrite like the
61
+         * following one (for nginx):
62
+        location ~ ^/([a-zA-Z0-9]+)$ {
63
+            rewrite ^/(.*)$ / break;
64
+        }
65
+         */
66
+        if (path.length > 1) {
67
+            roomnode = path.substr(1).toLowerCase();
68
+        } else {
69
+            roomnode = Math.random().toString(36).substr(2, 20);
70
+            window.history.pushState('VideoChat', 'Room: ' + roomnode, window.location.pathname + roomnode);
71
+        }
64 72
     }
65 73
     roomjid = roomnode + '@' + config.hosts.muc;
66 74
 

+ 1
- 0
config.js Dosyayı Görüntüle

@@ -4,6 +4,7 @@ var config = {
4 4
         muc: 'meet.jit.si', // FIXME: use XEP-0030
5 5
         bridge: 'jitsi-videobridge.lambada.jitsi.net' // FIXME: use XEP-0030
6 6
     },
7
+//  getroomnode: function (path) { return 'someprefixpossiblybasedonpath'; },
7 8
     useNicks: false,
8 9
     bosh: '//lambada.jitsi.net/http-bind' // FIXME: use xep-0156 for that
9 10
 };

Loading…
İptal
Kaydet