d->m accept emojis with longer names
This commit is contained in:
		
							parent
							
								
									95b6fddaa8
								
							
						
					
					
						commit
						ca988af2e0
					
				
					 4 changed files with 50 additions and 3 deletions
				
			
		| 
						 | 
					@ -158,7 +158,7 @@ async function messageToEvent(message, guild, options = {}, di) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 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.
 | 
							// 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.
 | 
							// So we scan the message ahead of time for all its emojis and ensure they are in the DB.
 | 
				
			||||||
		const emojiMatches = [...content.matchAll(/<(a?):([^:>]{2,20}):([0-9]+)>/g)]
 | 
							const emojiMatches = [...content.matchAll(/<(a?):([^:>]{2,64}):([0-9]+)>/g)]
 | 
				
			||||||
		const emojiDownloads = []
 | 
							const emojiDownloads = []
 | 
				
			||||||
		for (const match of emojiMatches) {
 | 
							for (const match of emojiMatches) {
 | 
				
			||||||
			const id = match[3]
 | 
								const id = match[3]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -403,3 +403,18 @@ test("message2event: mid-message small bridged emoji", async t => {
 | 
				
			||||||
		formatted_body: 'h is for <img data-mx-emoticon height="32" src="mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC" title=":hippo:" alt=":hippo:">!'
 | 
							formatted_body: 'h is for <img data-mx-emoticon height="32" src="mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC" title=":hippo:" alt=":hippo:">!'
 | 
				
			||||||
	}])
 | 
						}])
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test("message2event: emoji triple long name", async t => {
 | 
				
			||||||
 | 
						const events = await messageToEvent(data.message.emoji_triple_long_name, data.guild.general, {})
 | 
				
			||||||
 | 
						t.deepEqual(events, [{
 | 
				
			||||||
 | 
							$type: "m.room.message",
 | 
				
			||||||
 | 
							"m.mentions": {},
 | 
				
			||||||
 | 
							msgtype: "m.text",
 | 
				
			||||||
 | 
							body: ":brillillillilliant_move::brillillillilliant_move::brillillillilliant_move:",
 | 
				
			||||||
 | 
							format: "org.matrix.custom.html",
 | 
				
			||||||
 | 
							formatted_body:
 | 
				
			||||||
 | 
								  '<img data-mx-emoticon height="32" src="mxc://cadence.moe/scfRIDOGKWFDEBjVXocWYQHik" title=":brillillillilliant_move:" alt=":brillillillilliant_move:">'
 | 
				
			||||||
 | 
								+ '<img data-mx-emoticon height="32" src="mxc://cadence.moe/scfRIDOGKWFDEBjVXocWYQHik" title=":brillillillilliant_move:" alt=":brillillillilliant_move:">'
 | 
				
			||||||
 | 
								+ '<img data-mx-emoticon height="32" src="mxc://cadence.moe/scfRIDOGKWFDEBjVXocWYQHik" title=":brillillillilliant_move:" alt=":brillillillilliant_move:">'
 | 
				
			||||||
 | 
						}])
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,12 +74,14 @@ INSERT INTO emoji (id, name, animated, mxc_url) VALUES
 | 
				
			||||||
('230201364309868544', 'hippo', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'),
 | 
					('230201364309868544', 'hippo', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'),
 | 
				
			||||||
('393635038903926784', 'hipposcope', 1, 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc'),
 | 
					('393635038903926784', 'hipposcope', 1, 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc'),
 | 
				
			||||||
('362741439211503616', 'bn_re', 0, 'mxc://cadence.moe/OIpqpfxTnHKokcsYqDusxkBT'),
 | 
					('362741439211503616', 'bn_re', 0, 'mxc://cadence.moe/OIpqpfxTnHKokcsYqDusxkBT'),
 | 
				
			||||||
('551636841284108289', 'ae_botrac4r', 0, 'mxc://cadence.moe/skqfuItqxNmBYekzmVKyoLzs');
 | 
					('551636841284108289', 'ae_botrac4r', 0, 'mxc://cadence.moe/skqfuItqxNmBYekzmVKyoLzs'),
 | 
				
			||||||
 | 
					('975572106295259148', 'brillillillilliant_move', 0, 'mxc://cadence.moe/scfRIDOGKWFDEBjVXocWYQHik');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
INSERT INTO member_cache (room_id, mxid, displayname, avatar_url) VALUES
 | 
					INSERT INTO member_cache (room_id, mxid, displayname, avatar_url) VALUES
 | 
				
			||||||
('!kLRqKKUQXcibIMtOpl:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', NULL),
 | 
					('!kLRqKKUQXcibIMtOpl:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', NULL),
 | 
				
			||||||
('!BpMdOUkWWhFxmTrENV:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'malformed mxc'),
 | 
					('!BpMdOUkWWhFxmTrENV:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'malformed mxc'),
 | 
				
			||||||
('!fGgIymcYWOqjbSRUdV:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'),
 | 
					('!fGgIymcYWOqjbSRUdV:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'),
 | 
				
			||||||
('!PnyBKvUBOhjuCucEfk:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU');
 | 
					('!PnyBKvUBOhjuCucEfk:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'),
 | 
				
			||||||
 | 
					('!maggESguZBqGBZtSnr:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
COMMIT;
 | 
					COMMIT;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										30
									
								
								test/data.js
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								test/data.js
									
										
									
									
									
								
							| 
						 | 
					@ -1038,6 +1038,36 @@ module.exports = {
 | 
				
			||||||
			flags: 0,
 | 
								flags: 0,
 | 
				
			||||||
			components: []
 | 
								components: []
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							emoji_triple_long_name: {
 | 
				
			||||||
 | 
								id: "1156394116540805170",
 | 
				
			||||||
 | 
								type: 0,
 | 
				
			||||||
 | 
								content: "<:brillillillilliant_move:975572106295259148><:brillillillilliant_move:975572106295259148><:brillillillilliant_move:975572106295259148>",
 | 
				
			||||||
 | 
								channel_id: "112760669178241024",
 | 
				
			||||||
 | 
								author: {
 | 
				
			||||||
 | 
									id: "111604486476181504",
 | 
				
			||||||
 | 
									username: "kyuugryphon",
 | 
				
			||||||
 | 
									avatar: "e4ce31267ca524d19be80e684d4cafa1",
 | 
				
			||||||
 | 
									discriminator: "0",
 | 
				
			||||||
 | 
									public_flags: 0,
 | 
				
			||||||
 | 
									flags: 0,
 | 
				
			||||||
 | 
									banner: null,
 | 
				
			||||||
 | 
									accent_color: null,
 | 
				
			||||||
 | 
									global_name: "KyuuGryphon",
 | 
				
			||||||
 | 
									avatar_decoration_data: null,
 | 
				
			||||||
 | 
									banner_color: null
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								attachments: [],
 | 
				
			||||||
 | 
								embeds: [],
 | 
				
			||||||
 | 
								mentions: [],
 | 
				
			||||||
 | 
								mention_roles: [],
 | 
				
			||||||
 | 
								pinned: false,
 | 
				
			||||||
 | 
								mention_everyone: false,
 | 
				
			||||||
 | 
								tts: false,
 | 
				
			||||||
 | 
								timestamp: "2023-09-27T00:57:22.147000+00:00",
 | 
				
			||||||
 | 
								edited_timestamp: null,
 | 
				
			||||||
 | 
								flags: 0,
 | 
				
			||||||
 | 
								components: []
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	message_with_embeds: {
 | 
						message_with_embeds: {
 | 
				
			||||||
		nothing_but_a_field: {
 | 
							nothing_but_a_field: {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue