make hardcoded "cadence.moe" configurable

This commit is contained in:
Cadence Ember 2023-08-23 12:45:19 +12:00
parent 92cd628a6c
commit 458a620f4a
5 changed files with 10 additions and 7 deletions

View file

@ -2,6 +2,7 @@
const assert = require("assert").strict const assert = require("assert").strict
const DiscordTypes = require("discord-api-types/v10") const DiscordTypes = require("discord-api-types/v10")
const reg = require("../../matrix/read-registration")
const passthrough = require("../../passthrough") const passthrough = require("../../passthrough")
const { discord, sync, db } = passthrough const { discord, sync, db } = passthrough
@ -85,7 +86,7 @@ async function channelToKState(channel, guild) {
"m.room.guest_access/": {guest_access: "can_join"}, "m.room.guest_access/": {guest_access: "can_join"},
"m.room.history_visibility/": {history_visibility}, "m.room.history_visibility/": {history_visibility},
[`m.space.parent/${spaceID}`]: { [`m.space.parent/${spaceID}`]: {
via: ["cadence.moe"], // TODO: put the proper server here via: [reg.ooye.server_name],
canonical: true canonical: true
}, },
"m.room.join_rules/": { "m.room.join_rules/": {
@ -252,7 +253,7 @@ async function _syncSpaceMember(channel, spaceID, roomID) {
&& !channel["thread_metadata"]?.archived // archived threads do not belong in the space (don't offer people conversations that are no longer relevant) && !channel["thread_metadata"]?.archived // archived threads do not belong in the space (don't offer people conversations that are no longer relevant)
) { ) {
spaceEventContent = { spaceEventContent = {
via: ["cadence.moe"] // TODO: use the proper server via: [reg.ooye.server_name]
} }
} }
const spaceDiff = ks.diffKState(spaceKState, { const spaceDiff = ks.diffKState(spaceKState, {

View file

@ -21,7 +21,7 @@ async function createSim(user) {
// Choose sim name // Choose sim name
const simName = userToMxid.userToSimName(user) const simName = userToMxid.userToSimName(user)
const localpart = reg.ooye.namespace_prefix + simName const localpart = reg.ooye.namespace_prefix + simName
const mxid = "@" + localpart + ":cadence.moe" const mxid = `@${localpart}:${reg.ooye.server_name}`
// Save chosen name in the database forever // Save chosen name in the database forever
// Making this database change right away so that in a concurrent registration, the 2nd registration will already have generated a different localpart because it can see this row when it generates // Making this database change right away so that in a concurrent registration, the 2nd registration will already have generated a different localpart because it can see this row when it generates

View file

@ -11,6 +11,7 @@ function eventSenderIsFromDiscord(sender) {
// If it's from a user in the bridge's namespace, then it originated from discord // If it's from a user in the bridge's namespace, then it originated from discord
// This includes messages sent by the appservice's bot user, because that is what's used for webhooks // This includes messages sent by the appservice's bot user, because that is what's used for webhooks
// TODO: It would be nice if bridge system messages wouldn't trigger this check and could be bridged from matrix to discord, while webhook reflections would remain ignored... // TODO: It would be nice if bridge system messages wouldn't trigger this check and could be bridged from matrix to discord, while webhook reflections would remain ignored...
// TODO that only applies to the above todo: But you'd have to watch out for the /icon command, where the bridge bot would set the room avatar, and that shouldn't be reflected into the room a second time.
if (userRegex.some(x => sender.match(x))) { if (userRegex.some(x => sender.match(x))) {
return true return true
} }

View file

@ -25,8 +25,8 @@ const reg = require("./matrix/read-registration")
const avatarUrl = await file.uploadDiscordFileToMxc("https://cadence.moe/friends/out_of_your_element_rev_2.jpg") const avatarUrl = await file.uploadDiscordFileToMxc("https://cadence.moe/friends/out_of_your_element_rev_2.jpg")
// set profile data on homeserver... // set profile data on homeserver...
await api.profileSetDisplayname(`@${reg.sender_localpart}:cadence.moe`, "Out Of Your Element") await api.profileSetDisplayname(`@${reg.sender_localpart}:${reg.ooye.server_name}`, "Out Of Your Element")
await api.profileSetAvatarUrl(`@${reg.sender_localpart}:cadence.moe`, avatarUrl) await api.profileSetAvatarUrl(`@${reg.sender_localpart}:${reg.ooye.server_name}`, avatarUrl)
// database ddl... // database ddl...

5
types.d.ts vendored
View file

@ -19,6 +19,7 @@ export type AppServiceRegistrationConfig = {
ooye: { ooye: {
namespace_prefix: string namespace_prefix: string
max_file_size: number max_file_size: number
server_name: string
} }
} }
@ -27,7 +28,7 @@ export type WebhookCreds = {
token: string token: string
} }
namespace Event { export namespace Event {
export type Outer<T> = { export type Outer<T> = {
type: string type: string
room_id: string room_id: string
@ -92,7 +93,7 @@ namespace Event {
} }
} }
namespace R { export namespace R {
export type RoomCreated = { export type RoomCreated = {
room_id: string room_id: string
} }