Compare commits
No commits in common. "ac40c54e40e3779c231d9d3245cf38f35a036ea0" and "cfaada67977cdf104c18a45068101754b1ff171f" have entirely different histories.
ac40c54e40
...
cfaada6797
6 changed files with 12 additions and 20 deletions
11
package-lock.json
generated
11
package-lock.json
generated
|
@ -31,7 +31,7 @@
|
||||||
"get-relative-path": "^1.0.2",
|
"get-relative-path": "^1.0.2",
|
||||||
"get-stream": "^6.0.1",
|
"get-stream": "^6.0.1",
|
||||||
"h3": "^1.12.0",
|
"h3": "^1.12.0",
|
||||||
"heatsync": "^2.7.0",
|
"heatsync": "^2.6.0",
|
||||||
"lru-cache": "^10.4.3",
|
"lru-cache": "^10.4.3",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"prettier-bytes": "^1.0.4",
|
"prettier-bytes": "^1.0.4",
|
||||||
|
@ -1868,15 +1868,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/heatsync": {
|
"node_modules/heatsync": {
|
||||||
"version": "2.7.0",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/heatsync/-/heatsync-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/heatsync/-/heatsync-2.6.0.tgz",
|
||||||
"integrity": "sha512-9ILOyyHFZKfIrqBmNz+fwKd+zupFE2UqFZ9k4FjRcMjNDp7GtW+K9n2htXLy3CwdDTRd6NV6BPxKvU51UqKIJA==",
|
"integrity": "sha512-UfemOt4Kg1hvhDj/Zz8sYa1pF73ul+tF19MYNisYoOymXoTo4iCZv2BDdCMFE1xvZ6YFjcMoekb/aeBU1uqFjQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"backtracker": "^4.0.0"
|
"backtracker": "^4.0.0"
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=14.6.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/html-es6cape": {
|
"node_modules/html-es6cape": {
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
"get-relative-path": "^1.0.2",
|
"get-relative-path": "^1.0.2",
|
||||||
"get-stream": "^6.0.1",
|
"get-stream": "^6.0.1",
|
||||||
"h3": "^1.12.0",
|
"h3": "^1.12.0",
|
||||||
"heatsync": "^2.7.0",
|
"heatsync": "^2.6.0",
|
||||||
"lru-cache": "^10.4.3",
|
"lru-cache": "^10.4.3",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"prettier-bytes": "^1.0.4",
|
"prettier-bytes": "^1.0.4",
|
||||||
|
|
|
@ -38,14 +38,13 @@ const guildPresenceSetting = new class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Presence extends sync.ReloadableClass {
|
class Presence {
|
||||||
/** @type {string} */ userID
|
/** @type {string} */ userID
|
||||||
/** @type {{presence: "online" | "offline" | "unavailable", status_msg?: string}} */ data
|
/** @type {{presence: "online" | "offline" | "unavailable", status_msg?: string}} */ data
|
||||||
/** @private @type {?string | undefined} */ mxid
|
/** @private @type {?string | undefined} */ mxid
|
||||||
/** @private @type {number} */ delay = Math.random()
|
/** @private @type {number} */ delay = Math.random()
|
||||||
|
|
||||||
constructor(userID) {
|
constructor(userID) {
|
||||||
super()
|
|
||||||
this.userID = userID
|
this.userID = userID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +66,12 @@ class Presence extends sync.ReloadableClass {
|
||||||
// This random delay will space them out over the whole 28 second cycle.
|
// This random delay will space them out over the whole 28 second cycle.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
api.setPresence(this.data, mxid).catch(() => {})
|
api.setPresence(this.data, mxid).catch(() => {})
|
||||||
}, this.delay * presenceLoopInterval).unref()
|
}, this.delay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sync.reloadClassMethods(Presence)
|
|
||||||
|
|
||||||
const presenceTracker = new class {
|
const presenceTracker = new class {
|
||||||
/** @private @type {Map<string, Presence>} userID -> Presence */ presences = sync.remember(() => new Map())
|
/** @private @type {Map<string, Presence>} userID -> Presence */ presences
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
sync.addTemporaryInterval(() => this.syncPresences(), presenceLoopInterval)
|
sync.addTemporaryInterval(() => this.syncPresences(), presenceLoopInterval)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
const mixin = require("@cloudrac3r/mixin-deep")
|
const mixin = require("@cloudrac3r/mixin-deep")
|
||||||
const stream = require("stream")
|
const stream = require("stream")
|
||||||
const {ReadableStream} = require("stream/web")
|
|
||||||
const getStream = require("get-stream")
|
const getStream = require("get-stream")
|
||||||
|
|
||||||
const {reg, writeRegistration} = require("./read-registration.js")
|
const {reg, writeRegistration} = require("./read-registration.js")
|
||||||
|
@ -31,18 +30,18 @@ async function mreq(method, url, body, extra = {}) {
|
||||||
} else if (body instanceof stream.Readable && reg.ooye.content_length_workaround) {
|
} else if (body instanceof stream.Readable && reg.ooye.content_length_workaround) {
|
||||||
body = await getStream.buffer(body)
|
body = await getStream.buffer(body)
|
||||||
} else if (body instanceof ReadableStream && reg.ooye.content_length_workaround) {
|
} else if (body instanceof ReadableStream && reg.ooye.content_length_workaround) {
|
||||||
body = await stream.consumers.buffer(stream.Readable.fromWeb(body))
|
body = await stream.consumers.buffer(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {RequestInit} */
|
/** @type {RequestInit} */
|
||||||
const opts = mixin({
|
const opts = {
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${reg.as_token}`
|
Authorization: `Bearer ${reg.as_token}`
|
||||||
},
|
},
|
||||||
...(body && {duplex: "half"}), // https://github.com/octokit/request.js/pull/571/files
|
...extra
|
||||||
}, extra)
|
}
|
||||||
// console.log(baseUrl + url, opts)
|
// console.log(baseUrl + url, opts)
|
||||||
const res = await fetch(baseUrl + url, opts)
|
const res = await fetch(baseUrl + url, opts)
|
||||||
const root = await res.json()
|
const root = await res.json()
|
||||||
|
|
|
@ -19,7 +19,6 @@ const eventDispatcher = sync.require("./d2m/event-dispatcher")
|
||||||
const updatePins = sync.require("./d2m/actions/update-pins")
|
const updatePins = sync.require("./d2m/actions/update-pins")
|
||||||
const speedbump = sync.require("./d2m/actions/speedbump")
|
const speedbump = sync.require("./d2m/actions/speedbump")
|
||||||
const ks = sync.require("./matrix/kstate")
|
const ks = sync.require("./matrix/kstate")
|
||||||
const setPresence = sync.require("./d2m/actions/set-presence")
|
|
||||||
const guildID = "112760669178241024"
|
const guildID = "112760669178241024"
|
||||||
|
|
||||||
const extraContext = {}
|
const extraContext = {}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
const {ReadableStream} = require("stream/web")
|
|
||||||
const {test} = require("supertape")
|
const {test} = require("supertape")
|
||||||
const {router} = require("../../test/web")
|
const {router} = require("../../test/web")
|
||||||
const assert = require("assert").strict
|
const assert = require("assert").strict
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue