Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Augmentile
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
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Auglement
Augmentile
Commits
76ac3298
Verified
Commit
76ac3298
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Fix initialisation of matrix backend
parent
9a6dbbfc
No related branches found
No related tags found
No related merge requests found
Pipeline
#7315
failed
4 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/backends/matrix.js
+11
-2
11 additions, 2 deletions
src/backends/matrix.js
src/utils.js
+41
-0
41 additions, 0 deletions
src/utils.js
with
52 additions
and
2 deletions
src/backends/matrix.js
+
11
−
2
View file @
76ac3298
...
...
@@ -15,12 +15,21 @@
import
{
BaseBackend
}
from
'
./base
'
;
import
*
as
sdk
from
'
matrix-js-sdk
'
;
import
*
as
utils
from
'
../utils
'
;
class
MatrixBackend
extends
BaseBackend
{
constructor
(
userId
,
homeServerUrl
)
{
constructor
(
userId
)
{
super
(
userId
);
}
set
userId
(
value
)
{
if
(
value
!==
undefined
)
{
const
matrixId
=
utils
.
splitMatrixId
(
value
);
const
homeServerUrl
=
'
https://
'
+
matrixId
.
homeServer
this
.
api
=
sdk
.
createClient
(
homeServerUrl
);
this
.
api
=
sdk
.
createClient
(
homeServerUrl
);
this
.
userId
=
value
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/utils.js
0 → 100644
+
41
−
0
View file @
76ac3298
/* Copyright 2021 Dominik George <nik@naturalnet.de>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Split a Matrix ID into local part and homeserver
*
* @param {string} matrixId
*
* @example
* splitMatrixId('@foo:example.com')
* // => {'localPart': 'foo', 'homeServer': 'example.com'}
*/
export
function
splitMatrixId
(
matrixId
)
{
if
(
typeof
matrixId
!==
'
string
'
)
{
throw
'
Passed Matrix ID must be a string
'
;
}
else
if
(
matrixId
.
substr
(
0
,
1
)
!==
'
@
'
)
{
throw
'
Passed Matrix ID must begin with @
'
;
}
else
if
(
matrixId
.
indexOf
(
'
:
'
)
<
2
)
{
throw
'
Passed Matrix ID must contain : to separate local part and home server
'
;
}
const
localPart
=
matrixId
.
substr
(
1
).
substr
(
0
,
matrixId
.
indexOf
(
'
:
'
));
const
homeServer
=
matrixId
.
substr
(
matrixId
.
indexOf
(
'
:
'
)
+
1
);
return
{
'
localPart
'
:
localPart
,
'
homeServer
'
:
homeServer
}
}
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