diff --git a/d2m/actions/create-room.js b/d2m/actions/create-room.js index 166d52f..c8f0661 100644 --- a/d2m/actions/create-room.js +++ b/d2m/actions/create-room.js @@ -2,6 +2,7 @@ const assert = require("assert").strict const DiscordTypes = require("discord-api-types/v10") +const reg = require("../../matrix/read-registration") const passthrough = require("../../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.history_visibility/": {history_visibility}, [`m.space.parent/${spaceID}`]: { - via: ["cadence.moe"], // TODO: put the proper server here + via: [reg.ooye.server_name], canonical: true }, "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) ) { spaceEventContent = { - via: ["cadence.moe"] // TODO: use the proper server + via: [reg.ooye.server_name] } } const spaceDiff = ks.diffKState(spaceKState, { diff --git a/d2m/actions/register-user.js b/d2m/actions/register-user.js index a33cecc..00a985c 100644 --- a/d2m/actions/register-user.js +++ b/d2m/actions/register-user.js @@ -21,7 +21,7 @@ async function createSim(user) { // Choose sim name const simName = userToMxid.userToSimName(user) 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 // 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 diff --git a/m2d/converters/utils.js b/m2d/converters/utils.js index 108da1f..7b9c504 100644 --- a/m2d/converters/utils.js +++ b/m2d/converters/utils.js @@ -11,6 +11,7 @@ function eventSenderIsFromDiscord(sender) { // 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 // 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))) { return true } diff --git a/seed.js b/seed.js index d84ca8d..e513f63 100644 --- a/seed.js +++ b/seed.js @@ -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") // set profile data on homeserver... - await api.profileSetDisplayname(`@${reg.sender_localpart}:cadence.moe`, "Out Of Your Element") - await api.profileSetAvatarUrl(`@${reg.sender_localpart}:cadence.moe`, avatarUrl) + await api.profileSetDisplayname(`@${reg.sender_localpart}:${reg.ooye.server_name}`, "Out Of Your Element") + await api.profileSetAvatarUrl(`@${reg.sender_localpart}:${reg.ooye.server_name}`, avatarUrl) // database ddl... diff --git a/types.d.ts b/types.d.ts index faf4c70..2ba8d1d 100644 --- a/types.d.ts +++ b/types.d.ts @@ -19,6 +19,7 @@ export type AppServiceRegistrationConfig = { ooye: { namespace_prefix: string max_file_size: number + server_name: string } } @@ -27,7 +28,7 @@ export type WebhookCreds = { token: string } -namespace Event { +export namespace Event { export type Outer = { type: string room_id: string @@ -92,7 +93,7 @@ namespace Event { } } -namespace R { +export namespace R { export type RoomCreated = { room_id: string }