Skip to content

Fix Ban command renderer giving useless results.#1120

Open
FSG-Cat wants to merge 3 commits into
mainfrom
FSG-Cat/Fix-Prompt-Pills
Open

Fix Ban command renderer giving useless results.#1120
FSG-Cat wants to merge 3 commits into
mainfrom
FSG-Cat/Fix-Prompt-Pills

Conversation

@FSG-Cat
Copy link
Copy Markdown
Member

@FSG-Cat FSG-Cat commented May 5, 2026

Fixes: #730
Fixes: #551

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: fdc9690

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
draupnir Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread apps/draupnir/src/utils.ts Outdated
Comment on lines +40 to +44
export function matrixToPermalink(roomIdOrAlias: string, viaServer: string): string {
return `https://matrix.to/#/${encodeURIComponent(roomIdOrAlias)}?via=${encodeURIComponent(
viaServer
)}`;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the MatrixRoomID, MatrixRoomAlias or Permalinks utilities from matrix-basic-types for this.

Comment on lines +46 to +56
/**
* Build a matrix.to permalink for a room id or alias using the bot's homeserver derived
* from the provided client MXID.
*/
export function matrixToPermalinkFromClientUser(
roomIdOrAlias: string,
clientUserID: StringUserID
): string {
const via = userServerName(clientUserID);
return matrixToPermalink(roomIdOrAlias, via);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly there is MatrixUserID and Permalinks

Comment on lines +4 to +18
import expect from "expect";
import { matrixToPermalink } from "../../../src/utils";

describe("matrixToPermalink", function () {
it("builds a matrix.to link with a single via", function () {
const room = "!wJbHKdEdDUKQRGGImO:feline.support";
const via = "feline.support";
const result = matrixToPermalink(room, via);
expect(result).toBe(
`https://matrix.to/#/${encodeURIComponent(room)}?via=${encodeURIComponent(
via
)}`
);
});
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this if you use matrix-basic-types mew

Comment on lines -88 to +89
.map((room) => MatrixRoomIDPresentationType.wrap(room)),
.map((room) =>
StringPresentationType.wrap(
matrixToPermalinkFromClientUser(room.toRoomIDOrAlias(), clientUserID)
)
),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use room.toPermalink() i think?

Comment on lines -88 to +89
.map((room) => MatrixRoomIDPresentationType.wrap(room)),
.map((room) =>
StringPresentationType.wrap(
matrixToPermalinkFromClientUser(room.toRoomIDOrAlias(), clientUserID)
)
),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is a good idea. Some clients will show this as a pill yes, But the presentation renderer for MatrixRoomID should really be fixed if it isn't forming pills that clients like.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isnt forming ANYTHING. its spitting bare room IDs and thats it. This PR improves that by spitting bare matrix.to links something clients atleast handle. Atleast Element Web does.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isnt forming ANYTHING. its spitting bare room IDs and thats it. This PR improves that by spitting bare matrix.to links something clients atleast handle. Atleast Element Web does.

In that case, the problem just is simply that when rendering the suggestions to matrix we use the plain text renderer instead of the DeadDocument one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Would you like to add the ban to a policy list?" only shows room IDs for some clients Missing pills when being prompted for what policy list to use.

2 participants