chore: lint and re-organize

This commit is contained in:
Rajeh Taher
2025-10-20 00:16:51 +03:00
parent cc3cd17392
commit 29318cf6c2
6 changed files with 34 additions and 40 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ export const makeNoiseHandler = ({
const certDecoded = decrypt(serverHello!.payload!)
const { intermediate: certIntermediate, leaf } = proto.CertChain.decode(certDecoded)
const { intermediate: certIntermediate /*leaf*/ } = proto.CertChain.decode(certDecoded)
// TODO: handle this leaf stuff
const { issuerSerial } = proto.CertChain.NoiseCertificate.Details.decode(certIntermediate!.details!)
+19 -22
View File
@@ -143,30 +143,27 @@ export const extractDeviceJids = (
for (const userResult of result) {
const { devices, id } = userResult as { devices: ParsedDeviceInfo; id: string }
let { user, domainType, server } = jidDecode(id)!
const decoded = jidDecode(id)!,
{ user, server } = decoded
let { domainType } = decoded
const deviceList = devices?.deviceList as DeviceListData[]
if (Array.isArray(deviceList)) {
for (const { id: device, keyIndex, isHosted } of deviceList) {
if (
(!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
((myUser !== user && myLid !== user) || myDevice !== device) && // either different user or if me user, not this device
(device === 0 || !!keyIndex) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
) {
if (isHosted) {
if (domainType === WAJIDDomains.LID) {
domainType = WAJIDDomains.HOSTED_LID
} else {
domainType = WAJIDDomains.HOSTED
}
}
extracted.push({
user,
device,
domainType,
server: getServerFromDomainType(server, domainType)
})
if (!Array.isArray(deviceList)) continue
for (const { id: device, keyIndex, isHosted } of deviceList) {
if (
(!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
((myUser !== user && myLid !== user) || myDevice !== device) && // either different user or if me user, not this device
(device === 0 || !!keyIndex) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
) {
if (isHosted) {
domainType = domainType === WAJIDDomains.LID ? WAJIDDomains.HOSTED_LID : WAJIDDomains.HOSTED
}
extracted.push({
user,
device,
domainType,
server: getServerFromDomainType(server, domainType)
})
}
}
}