Compare commits
5 Commits
43871634be
...
1821d3cb64
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1821d3cb64
|
||
|
|
1738dd8ad9
|
||
|
|
9fb8829901
|
||
|
|
e663a46242
|
||
|
|
f48933751d
|
23
.drone.yml
Normal file
23
.drone.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: node 14
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: node:14
|
||||
commands:
|
||||
- npm install
|
||||
- npm run build
|
||||
- npm test
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: node 16
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: node:16
|
||||
commands:
|
||||
- npm install
|
||||
- npm run build
|
||||
- npm test
|
||||
123
dist/build.js
vendored
123
dist/build.js
vendored
File diff suppressed because one or more lines are too long
1
dist/build.js.LICENSE.txt
vendored
Normal file
1
dist/build.js.LICENSE.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
||||
2
dist/build.js.map
vendored
2
dist/build.js.map
vendored
File diff suppressed because one or more lines are too long
221
package-lock.json
generated
221
package-lock.json
generated
@@ -15,6 +15,7 @@
|
||||
"chai": "^4.3.6",
|
||||
"mocha": "^10.0.0",
|
||||
"regenerator-runtime": "^0.13.9",
|
||||
"sinon": "^14.0.0",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
}
|
||||
@@ -1735,6 +1736,41 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@sinonjs/commons": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz",
|
||||
"integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"type-detect": "4.0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@sinonjs/fake-timers": {
|
||||
"version": "9.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz",
|
||||
"integrity": "sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sinonjs/samsam": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-6.1.1.tgz",
|
||||
"integrity": "sha512-cZ7rKJTLiE7u7Wi/v9Hc2fs3Ucc3jrWeMgPHbbTCeVAB2S0wOBbYlkJVeNSL04i7fdhT8wIbDq1zhC/PXTD2SA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^1.6.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"type-detect": "^4.0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@sinonjs/text-encoding": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz",
|
||||
"integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/eslint": {
|
||||
"version": "8.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.5.tgz",
|
||||
@@ -3137,6 +3173,12 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
@@ -3220,6 +3262,12 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/just-extend": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz",
|
||||
"integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/kind-of": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
||||
@@ -3270,6 +3318,12 @@
|
||||
"integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/lodash.get": {
|
||||
"version": "4.4.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
|
||||
"integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/log-symbols": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
|
||||
@@ -3493,6 +3547,19 @@
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/nise": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/nise/-/nise-5.1.1.tgz",
|
||||
"integrity": "sha512-yr5kW2THW1AkxVmCnKEh4nbYkJdB3I7LUkiUgOvEkOp414mc2UMaHMA7pjq1nYowhdoJZGwEKGaQVbxfpWj10A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^1.8.3",
|
||||
"@sinonjs/fake-timers": ">=5",
|
||||
"@sinonjs/text-encoding": "^0.7.1",
|
||||
"just-extend": "^4.0.2",
|
||||
"path-to-regexp": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-releases": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
|
||||
@@ -3613,6 +3680,15 @@
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz",
|
||||
"integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"isarray": "0.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/pathval": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
|
||||
@@ -3889,6 +3965,45 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/sinon": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-14.0.0.tgz",
|
||||
"integrity": "sha512-ugA6BFmE+WrJdh0owRZHToLd32Uw3Lxq6E6LtNRU+xTVBefx632h03Q7apXWRsRdZAJ41LB8aUfn2+O4jsDNMw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^1.8.3",
|
||||
"@sinonjs/fake-timers": "^9.1.2",
|
||||
"@sinonjs/samsam": "^6.1.1",
|
||||
"diff": "^5.0.0",
|
||||
"nise": "^5.1.1",
|
||||
"supports-color": "^7.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/sinon"
|
||||
}
|
||||
},
|
||||
"node_modules/sinon/node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/sinon/node_modules/supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
@@ -5646,6 +5761,41 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"@sinonjs/commons": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz",
|
||||
"integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type-detect": "4.0.8"
|
||||
}
|
||||
},
|
||||
"@sinonjs/fake-timers": {
|
||||
"version": "9.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz",
|
||||
"integrity": "sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"@sinonjs/samsam": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-6.1.1.tgz",
|
||||
"integrity": "sha512-cZ7rKJTLiE7u7Wi/v9Hc2fs3Ucc3jrWeMgPHbbTCeVAB2S0wOBbYlkJVeNSL04i7fdhT8wIbDq1zhC/PXTD2SA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1.6.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"type-detect": "^4.0.8"
|
||||
}
|
||||
},
|
||||
"@sinonjs/text-encoding": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz",
|
||||
"integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/eslint": {
|
||||
"version": "8.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.5.tgz",
|
||||
@@ -6727,6 +6877,12 @@
|
||||
"integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==",
|
||||
"dev": true
|
||||
},
|
||||
"isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
|
||||
"dev": true
|
||||
},
|
||||
"isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
@@ -6789,6 +6945,12 @@
|
||||
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
|
||||
"dev": true
|
||||
},
|
||||
"just-extend": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz",
|
||||
"integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==",
|
||||
"dev": true
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
||||
@@ -6827,6 +6989,12 @@
|
||||
"integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
|
||||
"dev": true
|
||||
},
|
||||
"lodash.get": {
|
||||
"version": "4.4.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
|
||||
"integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==",
|
||||
"dev": true
|
||||
},
|
||||
"log-symbols": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
|
||||
@@ -6984,6 +7152,19 @@
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true
|
||||
},
|
||||
"nise": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/nise/-/nise-5.1.1.tgz",
|
||||
"integrity": "sha512-yr5kW2THW1AkxVmCnKEh4nbYkJdB3I7LUkiUgOvEkOp414mc2UMaHMA7pjq1nYowhdoJZGwEKGaQVbxfpWj10A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1.8.3",
|
||||
"@sinonjs/fake-timers": ">=5",
|
||||
"@sinonjs/text-encoding": "^0.7.1",
|
||||
"just-extend": "^4.0.2",
|
||||
"path-to-regexp": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"node-releases": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
|
||||
@@ -7071,6 +7252,15 @@
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true
|
||||
},
|
||||
"path-to-regexp": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz",
|
||||
"integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"isarray": "0.0.1"
|
||||
}
|
||||
},
|
||||
"pathval": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
|
||||
@@ -7285,6 +7475,37 @@
|
||||
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
||||
"dev": true
|
||||
},
|
||||
"sinon": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-14.0.0.tgz",
|
||||
"integrity": "sha512-ugA6BFmE+WrJdh0owRZHToLd32Uw3Lxq6E6LtNRU+xTVBefx632h03Q7apXWRsRdZAJ41LB8aUfn2+O4jsDNMw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1.8.3",
|
||||
"@sinonjs/fake-timers": "^9.1.2",
|
||||
"@sinonjs/samsam": "^6.1.1",
|
||||
"diff": "^5.0.0",
|
||||
"nise": "^5.1.1",
|
||||
"supports-color": "^7.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"build": "NODE_ENV=production webpack",
|
||||
"dev": "webpack -w",
|
||||
"start": "npm run dev",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"test": "mocha tests/",
|
||||
"version": "npm run build && git add dist/"
|
||||
},
|
||||
"author": "Kosmos Contributors <mail@kosmos.org> (https://kosmos.org)",
|
||||
@@ -24,6 +24,7 @@
|
||||
"chai": "^4.3.6",
|
||||
"mocha": "^10.0.0",
|
||||
"regenerator-runtime": "^0.13.9",
|
||||
"sinon": "^14.0.0",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
||||
*/
|
||||
if (this.channelType === "room") {
|
||||
// Normal chatroom
|
||||
const channelName = this.channelName.replace(/#/,'');
|
||||
const channelName = this.channelName.replace(/^#/,'');
|
||||
this.channelPath = `${this.service.domain}/channels/${channelName}`;
|
||||
} else {
|
||||
// User direct messages
|
||||
@@ -489,7 +489,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
||||
* @private
|
||||
*/
|
||||
_buildArchiveObject () {
|
||||
const roomName = this.channelName.replace(/#/,'');
|
||||
const roomName = this.channelName.replace(/^#/,'');
|
||||
|
||||
const archive = {
|
||||
"@id": "chat-messages/"+this.service.domain+"/channels/"+roomName+"/",
|
||||
@@ -616,7 +616,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
||||
}
|
||||
|
||||
// Only update document if current date is newer than known "last"
|
||||
if (Date.parse(meta.last.replace('/','-')) > Date.parse(this.date)) {
|
||||
if (Date.parse(meta.last.replace(/\//g,'-')) > Date.parse(this.date)) {
|
||||
console.debug('[chat-messages]', 'Updating meta document for channel');
|
||||
meta.last = this.dateId;
|
||||
await this.client.storeObject('daily-archive-meta', this.metaPath, meta);
|
||||
@@ -630,7 +630,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
||||
// When creating a new meta doc, we need to find the oldest archive,
|
||||
// because older versions of the module did not write a meta doc.
|
||||
const first = await this._findFirstArchive();
|
||||
const roomName = this.channelName.replace(/#/,'');
|
||||
const roomName = this.channelName.replace(/^#/,'');
|
||||
|
||||
const meta = {
|
||||
'@id': `chat-messages/${this.service.domain}/channels/${roomName}/meta`,
|
||||
@@ -667,10 +667,10 @@ const ChatMessages = function (privateClient, publicClient) {
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
async _sync (obj) {
|
||||
console.debug(`[chat-messages] Writing archive object with ${obj.today.messages.length} messages`);
|
||||
async _sync (archive) {
|
||||
console.debug(`[chat-messages] Writing archive object with ${archive.today.messages.length} messages`);
|
||||
|
||||
return this.client.storeObject('daily-archive', this.path, obj).then(function(){
|
||||
return this.client.storeObject('daily-archive', this.path, archive).then(function(){
|
||||
console.debug('[chat-messages] Archive written to remote storage');
|
||||
return true;
|
||||
},function(error){
|
||||
|
||||
109
tests/chat-messages-spec.js
Normal file
109
tests/chat-messages-spec.js
Normal file
@@ -0,0 +1,109 @@
|
||||
const expect = require('chai').expect;
|
||||
const sandbox = require("sinon").createSandbox();
|
||||
const ChatMessages = require('../dist/build');
|
||||
|
||||
const rsClient = {
|
||||
declareType: function() {},
|
||||
getObject: function() {},
|
||||
getListing: function() {},
|
||||
storeObject: function() {},
|
||||
remove: function() {}
|
||||
}
|
||||
|
||||
|
||||
describe('ChatMessages', function () {
|
||||
|
||||
describe('constructor', function () {
|
||||
let chatMessages;
|
||||
|
||||
before(function() {
|
||||
chatMessages = new ChatMessages.builder(rsClient, rsClient);
|
||||
});
|
||||
|
||||
it('behaves like a remoteStorage module', function () {
|
||||
expect(chatMessages).to.be.an('object');
|
||||
expect(chatMessages.exports).to.be.an('object');
|
||||
});
|
||||
|
||||
it('exports the desired functionality', function () {
|
||||
expect(chatMessages.exports.DailyArchive).to.be.a('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('DailyArchive', function () {
|
||||
let archive;
|
||||
|
||||
before(function() {
|
||||
chatMessages = (new ChatMessages.builder(rsClient, rsClient)).exports;
|
||||
|
||||
archive = new chatMessages.DailyArchive({
|
||||
service: { protocol: 'IRC', domain: 'irc.libera.chat' },
|
||||
channelName: '#kosmos',
|
||||
date: new Date('2022-08-11')
|
||||
});
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
it('creates an archive instance with the desired properties', function () {
|
||||
expect(archive).to.be.an('object');
|
||||
expect(archive.service.protocol).to.eq('IRC');
|
||||
expect(archive.service.domain).to.eq('irc.libera.chat');
|
||||
expect(archive.channelName).to.eq('#kosmos');
|
||||
expect(archive.channelType).to.eq('room');
|
||||
expect(archive.date).to.be.a('date');
|
||||
expect(archive.parsedDate.year).to.eq(2022);
|
||||
expect(archive.parsedDate.month).to.eq('08');
|
||||
expect(archive.parsedDate.day).to.eq('11');
|
||||
expect(archive.dateId).to.eq('2022/08/11');
|
||||
expect(archive.isPublic).to.eq(false);
|
||||
expect(archive.channelPath).to.eq('irc.libera.chat/channels/kosmos');
|
||||
expect(archive.path).to.eq('irc.libera.chat/channels/kosmos/2022/08/11');
|
||||
expect(archive.metaPath).to.eq('irc.libera.chat/channels/kosmos/meta');
|
||||
expect(archive.client).to.eq(rsClient);
|
||||
expect(archive.previous).to.be.an('undefined');
|
||||
expect(archive.next).to.be.an('undefined');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#_updateArchiveMetaDocument', function () {
|
||||
describe('meta up to date', function () {
|
||||
before(function() {
|
||||
sandbox.stub(archive.client, 'getObject').withArgs(archive.metaPath)
|
||||
.returns({
|
||||
'@id': `chat-messages/irc.libera.chat/channels/kosmos/meta`,
|
||||
'@type': 'ChatChannelMeta',
|
||||
first: '2021/01/01', last: '2022/08/11'
|
||||
})
|
||||
sandbox.stub(archive.client, 'storeObject');
|
||||
});
|
||||
|
||||
it('does not store a new archive', async function () {
|
||||
await archive._updateArchiveMetaDocument();
|
||||
sandbox.assert.notCalled(archive.client.storeObject);
|
||||
});
|
||||
|
||||
after(function() { sandbox.restore() });
|
||||
});
|
||||
|
||||
describe('meta needs updating', function () {
|
||||
before(function() {
|
||||
sandbox.stub(archive.client, 'getObject').withArgs(archive.metaPath)
|
||||
.returns({
|
||||
'@id': `chat-messages/irc.libera.chat/channels/kosmos/meta`,
|
||||
'@type': 'ChatChannelMeta',
|
||||
first: '2021/01/01', last: '2022/08/10'
|
||||
})
|
||||
sandbox.stub(archive.client, 'storeObject');
|
||||
});
|
||||
|
||||
it('stores a new archive', async function () {
|
||||
await archive._updateArchiveMetaDocument();
|
||||
sandbox.assert.calledOnce(archive.client.storeObject);
|
||||
});
|
||||
|
||||
after(function() { sandbox.restore() });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user