Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
M
matrix-appservice-discord
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
salixor
matrix-appservice-discord
Validations
5f245e1c
Valider
5f245e1c
rédigé
Il y a 6 ans
par
Will Hunt
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Store prefixes
parent
641edc7d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/db/roomstore.ts
+8
-8
8 ajouts, 8 suppressions
src/db/roomstore.ts
src/db/userstore.ts
+4
-4
4 ajouts, 4 suppressions
src/db/userstore.ts
avec
12 ajouts
et
12 suppressions
src/db/roomstore.ts
+
8
−
8
Voir le fichier @
5f245e1c
...
@@ -156,10 +156,10 @@ export class DbRoomStore {
...
@@ -156,10 +156,10 @@ export class DbRoomStore {
public
async
getEntriesByMatrixId
(
matrixId
:
string
):
Promise
<
IRoomStoreEntry
[]
>
{
public
async
getEntriesByMatrixId
(
matrixId
:
string
):
Promise
<
IRoomStoreEntry
[]
>
{
const
cached
=
this
.
entriesMatrixIdCache
.
get
(
matrixId
);
const
cached
=
this
.
entriesMatrixIdCache
.
get
(
matrixId
);
if
(
cached
&&
cached
.
ts
+
ENTRY_CACHE_LIMETIME
>
Date
.
now
())
{
if
(
cached
&&
cached
.
ts
+
ENTRY_CACHE_LIMETIME
>
Date
.
now
())
{
MetricPeg
.
get
.
storeCall
(
"
getEntriesByMatrixId
"
,
true
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
getEntriesByMatrixId
"
,
true
);
return
cached
.
e
;
return
cached
.
e
;
}
}
MetricPeg
.
get
.
storeCall
(
"
getEntriesByMatrixId
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
getEntriesByMatrixId
"
,
false
);
const
entries
=
await
this
.
db
.
All
(
const
entries
=
await
this
.
db
.
All
(
"
SELECT * FROM room_entries WHERE matrix_id = $id
"
,
{
id
:
matrixId
},
"
SELECT * FROM room_entries WHERE matrix_id = $id
"
,
{
id
:
matrixId
},
);
);
...
@@ -193,7 +193,7 @@ export class DbRoomStore {
...
@@ -193,7 +193,7 @@ export class DbRoomStore {
}
}
public
async
getEntriesByMatrixIds
(
matrixIds
:
string
[]):
Promise
<
IRoomStoreEntry
[]
>
{
public
async
getEntriesByMatrixIds
(
matrixIds
:
string
[]):
Promise
<
IRoomStoreEntry
[]
>
{
MetricPeg
.
get
.
storeCall
(
"
getEntriesByMatrixIds
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
getEntriesByMatrixIds
"
,
false
);
const
mxIdMap
=
{
};
const
mxIdMap
=
{
};
matrixIds
.
forEach
((
mxId
,
i
)
=>
mxIdMap
[
i
]
=
mxId
);
matrixIds
.
forEach
((
mxId
,
i
)
=>
mxIdMap
[
i
]
=
mxId
);
const
sql
=
`SELECT * FROM room_entries WHERE matrix_id IN (
${
matrixIds
.
map
((
_
,
id
)
=>
`
\$
${
id
}
`
).
join
(
"
,
"
)}
)`
;
const
sql
=
`SELECT * FROM room_entries WHERE matrix_id IN (
${
matrixIds
.
map
((
_
,
id
)
=>
`
\$
${
id
}
`
).
join
(
"
,
"
)}
)`
;
...
@@ -226,7 +226,7 @@ export class DbRoomStore {
...
@@ -226,7 +226,7 @@ export class DbRoomStore {
}
}
public
async
linkRooms
(
matrixRoom
:
MatrixStoreRoom
,
remoteRoom
:
RemoteStoreRoom
)
{
public
async
linkRooms
(
matrixRoom
:
MatrixStoreRoom
,
remoteRoom
:
RemoteStoreRoom
)
{
MetricPeg
.
get
.
storeCall
(
"
linkRooms
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
linkRooms
"
,
false
);
await
this
.
upsertRoom
(
remoteRoom
);
await
this
.
upsertRoom
(
remoteRoom
);
const
values
=
{
const
values
=
{
...
@@ -249,7 +249,7 @@ export class DbRoomStore {
...
@@ -249,7 +249,7 @@ export class DbRoomStore {
}
}
public
async
getEntriesByRemoteRoomData
(
data
:
IRemoteRoomDataLazy
):
Promise
<
IRoomStoreEntry
[]
>
{
public
async
getEntriesByRemoteRoomData
(
data
:
IRemoteRoomDataLazy
):
Promise
<
IRoomStoreEntry
[]
>
{
MetricPeg
.
get
.
storeCall
(
"
getEntriesByRemoteRoomData
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
getEntriesByRemoteRoomData
"
,
false
);
Object
.
keys
(
data
).
filter
((
k
)
=>
typeof
(
data
[
k
])
===
"
boolean
"
).
forEach
((
k
)
=>
{
Object
.
keys
(
data
).
filter
((
k
)
=>
typeof
(
data
[
k
])
===
"
boolean
"
).
forEach
((
k
)
=>
{
data
[
k
]
=
Number
(
data
[
k
]);
data
[
k
]
=
Number
(
data
[
k
]);
});
});
...
@@ -276,13 +276,13 @@ export class DbRoomStore {
...
@@ -276,13 +276,13 @@ export class DbRoomStore {
}
}
public
async
removeEntriesByRemoteRoomId
(
remoteId
:
string
)
{
public
async
removeEntriesByRemoteRoomId
(
remoteId
:
string
)
{
MetricPeg
.
get
.
storeCall
(
"
removeEntriesByRemoteRoomId
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
removeEntriesByRemoteRoomId
"
,
false
);
await
this
.
db
.
Run
(
`DELETE FROM room_entries WHERE remote_id = $remoteId`
,
{
remoteId
});
await
this
.
db
.
Run
(
`DELETE FROM room_entries WHERE remote_id = $remoteId`
,
{
remoteId
});
await
this
.
db
.
Run
(
`DELETE FROM remote_room_data WHERE room_id = $remoteId`
,
{
remoteId
});
await
this
.
db
.
Run
(
`DELETE FROM remote_room_data WHERE room_id = $remoteId`
,
{
remoteId
});
}
}
public
async
removeEntriesByMatrixRoomId
(
matrixId
:
string
)
{
public
async
removeEntriesByMatrixRoomId
(
matrixId
:
string
)
{
MetricPeg
.
get
.
storeCall
(
"
removeEntriesByMatrixRoomId
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
removeEntriesByMatrixRoomId
"
,
false
);
const
entries
=
(
await
this
.
db
.
All
(
`SELECT * FROM room_entries WHERE matrix_id = $matrixId`
,
{
matrixId
}))
||
[];
const
entries
=
(
await
this
.
db
.
All
(
`SELECT * FROM room_entries WHERE matrix_id = $matrixId`
,
{
matrixId
}))
||
[];
await
Util
.
AsyncForEach
(
entries
,
async
(
entry
)
=>
{
await
Util
.
AsyncForEach
(
entries
,
async
(
entry
)
=>
{
if
(
entry
.
remote_id
)
{
if
(
entry
.
remote_id
)
{
...
@@ -294,7 +294,7 @@ export class DbRoomStore {
...
@@ -294,7 +294,7 @@ export class DbRoomStore {
}
}
private
async
upsertRoom
(
room
:
RemoteStoreRoom
)
{
private
async
upsertRoom
(
room
:
RemoteStoreRoom
)
{
MetricPeg
.
get
.
storeCall
(
"
upsertRoom
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
RoomStore.
upsertRoom
"
,
false
);
if
(
!
room
.
data
)
{
if
(
!
room
.
data
)
{
throw
new
Error
(
"
Tried to upsert a room with undefined data
"
);
throw
new
Error
(
"
Tried to upsert a room with undefined data
"
);
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/db/userstore.ts
+
4
−
4
Voir le fichier @
5f245e1c
...
@@ -54,10 +54,10 @@ export class DbUserStore {
...
@@ -54,10 +54,10 @@ export class DbUserStore {
public
async
getRemoteUser
(
remoteId
:
string
):
Promise
<
RemoteUser
|
null
>
{
public
async
getRemoteUser
(
remoteId
:
string
):
Promise
<
RemoteUser
|
null
>
{
const
cached
=
this
.
remoteUserCache
.
get
(
remoteId
);
const
cached
=
this
.
remoteUserCache
.
get
(
remoteId
);
if
(
cached
&&
cached
.
ts
+
ENTRY_CACHE_LIMETIME
>
Date
.
now
())
{
if
(
cached
&&
cached
.
ts
+
ENTRY_CACHE_LIMETIME
>
Date
.
now
())
{
MetricPeg
.
get
.
storeCall
(
"
getRemoteUser
"
,
true
);
MetricPeg
.
get
.
storeCall
(
"
UserStore.
getRemoteUser
"
,
true
);
return
cached
.
e
;
return
cached
.
e
;
}
}
MetricPeg
.
get
.
storeCall
(
"
getRemoteUser
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
UserStore.
getRemoteUser
"
,
false
);
const
row
=
await
this
.
db
.
Get
(
const
row
=
await
this
.
db
.
Get
(
"
SELECT * FROM user_entries WHERE remote_id = $id
"
,
{
id
:
remoteId
},
"
SELECT * FROM user_entries WHERE remote_id = $id
"
,
{
id
:
remoteId
},
...
@@ -89,7 +89,7 @@ export class DbUserStore {
...
@@ -89,7 +89,7 @@ export class DbUserStore {
}
}
public
async
setRemoteUser
(
user
:
RemoteUser
)
{
public
async
setRemoteUser
(
user
:
RemoteUser
)
{
MetricPeg
.
get
.
storeCall
(
"
setRemoteUser
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
UserStore.
setRemoteUser
"
,
false
);
this
.
remoteUserCache
.
delete
(
user
.
id
);
this
.
remoteUserCache
.
delete
(
user
.
id
);
const
existingData
=
await
this
.
db
.
Get
(
const
existingData
=
await
this
.
db
.
Get
(
"
SELECT * FROM remote_user_data WHERE remote_id = $remoteId
"
,
"
SELECT * FROM remote_user_data WHERE remote_id = $remoteId
"
,
...
@@ -160,7 +160,7 @@ AND guild_id = $guild_id`,
...
@@ -160,7 +160,7 @@ AND guild_id = $guild_id`,
}
}
public
async
linkUsers
(
matrixId
:
string
,
remoteId
:
string
)
{
public
async
linkUsers
(
matrixId
:
string
,
remoteId
:
string
)
{
MetricPeg
.
get
.
storeCall
(
"
linkUsers
"
,
false
);
MetricPeg
.
get
.
storeCall
(
"
UserStore.
linkUsers
"
,
false
);
// This is used ONCE in the bridge to link two IDs, so do not UPSURT data.
// This is used ONCE in the bridge to link two IDs, so do not UPSURT data.
try
{
try
{
await
this
.
db
.
Run
(
`INSERT INTO user_entries VALUES ($matrixId, $remoteId)`
,
{
await
this
.
db
.
Run
(
`INSERT INTO user_entries VALUES ($matrixId, $remoteId)`
,
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter