Remove hardcoded cadence.moe

This commit is contained in:
Cadence Ember 2024-09-25 13:37:54 +12:00
parent dbbb8281e6
commit 734c9a5838
3 changed files with 11 additions and 7 deletions

View file

@ -105,7 +105,8 @@ async function validateHomeserverOrigin(serverUrlPrompt, url) {
const serverNameResponse = await prompt({
type: "input",
name: "server_name",
message: "Homeserver name"
message: "Homeserver name",
validate: serverName => !!serverName.match(/[a-z][a-z.]+[a-z]/)
})
console.log("What is the URL of your homeserver?")
@ -176,7 +177,7 @@ async function validateHomeserverOrigin(serverUrlPrompt, url) {
message: "Client secret"
})
const template = getTemplateRegistration()
const template = getTemplateRegistration(serverNameResponse.server_name)
reg = {
...template,
url: bridgeOriginResponse.bridge_origin,

View file

@ -24,8 +24,11 @@ function writeRegistration(reg) {
fs.writeFileSync(registrationFilePath, JSON.stringify(reg, null, 2))
}
/** @returns {import("../types").InitialAppServiceRegistrationConfig} reg */
function getTemplateRegistration() {
/**
* @param {string} serverName
* @returns {import("../types").InitialAppServiceRegistrationConfig} reg
*/
function getTemplateRegistration(serverName) {
return {
id: "ooye",
as_token: crypto.randomBytes(32).toString("hex"),
@ -33,11 +36,11 @@ function getTemplateRegistration() {
namespaces: {
users: [{
exclusive: true,
regex: "@_ooye_.*:cadence.moe"
regex: `@_ooye_.*:${serverName}`
}],
aliases: [{
exclusive: true,
regex: "#_ooye_.*:cadence.moe"
regex: `#_ooye_.*:${serverName}`
}]
},
protocols: [

View file

@ -136,7 +136,7 @@ block body
form.d-flex.ai-center.g8
label.s-label.fl-grow1(for="autocreate")
| Create new Matrix rooms automatically
p.s-description If you want, OOYE can automatically create new Matrix rooms and link them when a new Discord channel is spoken in.
p.s-description If you want, OOYE can automatically create new Matrix rooms and link them when an unlinked Discord channel is spoken in.
- let value = select("guild_active", "autocreate", {guild_id}).pluck().get()
input(type="hidden" name="guild_id" value=guild_id)
input.s-toggle-switch.order-last#autocreate(name="autocreate" type="checkbox" hx-post="/api/autocreate" hx-indicator="#autocreate-loading" hx-disabled-elt="this" checked=value)