Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
43772d0b
Commit
43772d0b
authored
10 years ago
by
Emmanuel ROHEE
Browse files
Options
Downloads
Patches
Plain Diff
Support urlencoded room aliases in room URL
parent
cebceb7b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
webclient/app.js
+2
-2
2 additions, 2 deletions
webclient/app.js
webclient/room/room-controller.js
+27
-15
27 additions, 15 deletions
webclient/room/room-controller.js
with
29 additions
and
17 deletions
webclient/app.js
+
2
−
2
View file @
43772d0b
...
@@ -33,13 +33,13 @@ matrixWebClient.config(['$routeProvider', '$provide', '$httpProvider',
...
@@ -33,13 +33,13 @@ matrixWebClient.config(['$routeProvider', '$provide', '$httpProvider',
templateUrl
:
'
login/login.html
'
,
templateUrl
:
'
login/login.html
'
,
controller
:
'
LoginController
'
controller
:
'
LoginController
'
}).
}).
when
(
'
/room/:room_id
'
,
{
when
(
'
/room/:room_id
_or_alias
'
,
{
templateUrl
:
'
room/room.html
'
,
templateUrl
:
'
room/room.html
'
,
controller
:
'
RoomController
'
controller
:
'
RoomController
'
}).
}).
when
(
'
/room/
'
,
{
// room URL with room alias in it (ex: http://127.0.0.1:8000/#/room/#public:localhost:8080) will come here.
when
(
'
/room/
'
,
{
// room URL with room alias in it (ex: http://127.0.0.1:8000/#/room/#public:localhost:8080) will come here.
// The reason is that 2nd hash key breaks routeProvider parameters cutting so that the URL will not match with
// The reason is that 2nd hash key breaks routeProvider parameters cutting so that the URL will not match with
// the previous '/room/:room_id' URL rule
// the previous '/room/:room_id
_or_alias
' URL rule
templateUrl
:
'
room/room.html
'
,
templateUrl
:
'
room/room.html
'
,
controller
:
'
RoomController
'
controller
:
'
RoomController
'
}).
}).
...
...
This diff is collapsed.
Click to expand it.
webclient/room/room-controller.js
+
27
−
15
View file @
43772d0b
...
@@ -109,8 +109,8 @@ angular.module('RoomController', ['ngSanitize'])
...
@@ -109,8 +109,8 @@ angular.module('RoomController', ['ngSanitize'])
'
use strict
'
;
'
use strict
'
;
var
MESSAGES_PER_PAGINATION
=
30
;
var
MESSAGES_PER_PAGINATION
=
30
;
// Room ids. C
hecked, c
omputed and resolved in onInit
// Room ids. Computed and resolved in onInit
$scope
.
room_id
=
$routeParams
.
room_i
d
;
$scope
.
room_id
=
undefine
d
;
$scope
.
room_alias
=
undefined
;
$scope
.
room_alias
=
undefined
;
$scope
.
state
=
{
$scope
.
state
=
{
...
@@ -347,27 +347,39 @@ angular.module('RoomController', ['ngSanitize'])
...
@@ -347,27 +347,39 @@ angular.module('RoomController', ['ngSanitize'])
console
.
log
(
"
onInit
"
);
console
.
log
(
"
onInit
"
);
// Does the room ID provided in the URL?
// Does the room ID provided in the URL?
if
(
$scope
.
room_id
)
{
var
room_id_or_alias
;
// Yes, we can start right now
if
(
$routeParams
.
room_id_or_alias
)
{
room_id_or_alias
=
decodeURIComponent
(
$routeParams
.
room_id_or_alias
);
}
if
(
room_id_or_alias
&&
'
!
'
===
room_id_or_alias
[
0
])
{
// Yes. We can start right now
$scope
.
room_id
=
room_id_or_alias
;
$scope
.
room_alias
=
matrixService
.
getRoomIdToAliasMapping
(
$scope
.
room_id
);
$scope
.
room_alias
=
matrixService
.
getRoomIdToAliasMapping
(
$scope
.
room_id
);
onInit2
();
onInit2
();
}
}
else
{
else
{
// No
, t
he URL contains the room alias. Get this alias.
// No
. T
he URL contains the room alias. Get this alias.
// ie: extract #public:localhost:8080 from http://127.0.0.1:8000/#/room/#public:localhost:8080
if
(
room_id_or_alias
)
{
if
(
3
===
location
.
hash
.
split
(
"
#
"
).
length
)
{
// The room alias was passed urlencoded, use it as is
$scope
.
room_alias
=
"
#
"
+
location
.
hash
.
split
(
"
#
"
)[
2
]
;
$scope
.
room_alias
=
room_id_or_alias
;
}
}
else
{
else
{
// In case of issue, go to the default page
// Else get the room alias by hand from the URL
console
.
log
(
"
Error: cannot extract room alias
"
);
// ie: extract #public:localhost:8080 from http://127.0.0.1:8000/#/room/#public:localhost:8080
$location
.
path
(
"
/
"
);
if
(
3
===
location
.
hash
.
split
(
"
#
"
).
length
)
{
return
;
$scope
.
room_alias
=
"
#
"
+
location
.
hash
.
split
(
"
#
"
)[
2
];
}
else
{
// In case of issue, go to the default page
console
.
log
(
"
Error: cannot extract room alias
"
);
$location
.
path
(
"
/
"
);
return
;
}
}
}
console
.
log
(
"
Resolving alias:
"
+
$scope
.
room_alias
);
// Need a room ID required in Matrix API requests
// Need a room ID required in Matrix API requests
console
.
log
(
"
Resolving alias:
"
+
$scope
.
room_alias
);
matrixService
.
resolveRoomAlias
(
$scope
.
room_alias
).
then
(
function
(
response
)
{
matrixService
.
resolveRoomAlias
(
$scope
.
room_alias
).
then
(
function
(
response
)
{
$scope
.
room_id
=
response
.
data
.
room_id
;
$scope
.
room_id
=
response
.
data
.
room_id
;
console
.
log
(
"
-> Room ID:
"
+
$scope
.
room_id
);
console
.
log
(
"
-> Room ID:
"
+
$scope
.
room_id
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment