Compare commits
2 commits
b16d731ddb
...
f287806bcd
| Author | SHA1 | Date | |
|---|---|---|---|
| f287806bcd | |||
| 45285a4835 |
3 changed files with 29 additions and 17 deletions
|
|
@ -474,6 +474,12 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
content = transformAttachmentLinks(content)
|
||||
content = await transformContentMessageLinks(content)
|
||||
|
||||
// Remove smalltext from non-bots (I don't like it). Webhooks included due to PluralKit.
|
||||
const isHumanOrDataMissing = !message.author?.bot
|
||||
if (isHumanOrDataMissing || dUtils.isWebhookMessage(message)) {
|
||||
content = content.replaceAll(/^-# +([^\n].*?)/gm, "...$1")
|
||||
}
|
||||
|
||||
// Handling emojis that we don't know about. The emoji has to be present in the DB for it to be picked up in the emoji markdown converter.
|
||||
// So we scan the message ahead of time for all its emojis and ensure they are in the DB.
|
||||
const emojiMatches = [...content.matchAll(/<(a?):([^:>]{1,64}):([0-9]+)>/g)]
|
||||
|
|
@ -850,8 +856,10 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
}
|
||||
|
||||
const {body, formatted_body} = stack[0].get()
|
||||
if (body.trim().length) {
|
||||
await addTextEvent(body, formatted_body, "m.text")
|
||||
}
|
||||
}
|
||||
|
||||
// Then polls
|
||||
if (message.poll) {
|
||||
|
|
|
|||
|
|
@ -1605,3 +1605,18 @@ test("message2event: multiple-choice poll", async t => {
|
|||
"org.matrix.msc1767.text": "more than one answer allowed\n1. [😭] no\n2. oh no\n3. oh noooooo"
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event: smalltext from regular user", async t => {
|
||||
const events = await messageToEvent({
|
||||
content: "-# hmm",
|
||||
author: {
|
||||
bot: false
|
||||
}
|
||||
})
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
"m.mentions": {},
|
||||
body: "...hmm"
|
||||
}])
|
||||
})
|
||||
|
|
|
|||
21
test/data.js
21
test/data.js
|
|
@ -4987,31 +4987,20 @@ module.exports = {
|
|||
edited_timestamp: null,
|
||||
flags: 32768,
|
||||
author: {
|
||||
id: '772659086046658620',
|
||||
username: 'cadence.worm',
|
||||
id: '466378653216014359',
|
||||
username: 'PluralKit',
|
||||
avatar: '466df0c98b1af1e1388f595b4c1ad1b9',
|
||||
discriminator: '0',
|
||||
public_flags: 0,
|
||||
flags: 0,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: 'cadence',
|
||||
global_name: 'PluralKit',
|
||||
avatar_decoration_data: null,
|
||||
collectibles: null,
|
||||
display_name_styles: null,
|
||||
banner_color: null,
|
||||
clan: {
|
||||
identity_guild_id: '532245108070809601',
|
||||
identity_enabled: true,
|
||||
tag: 'doll',
|
||||
badge: 'dba08126b4e810a0e096cc7cd5bc37f0'
|
||||
},
|
||||
primary_guild: {
|
||||
identity_guild_id: '532245108070809601',
|
||||
identity_enabled: true,
|
||||
tag: 'doll',
|
||||
badge: 'dba08126b4e810a0e096cc7cd5bc37f0'
|
||||
}
|
||||
banner_color: null
|
||||
},
|
||||
components: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue