bridge both ways and prevent reflections
This commit is contained in:
		
							parent
							
								
									3578ca28b5
								
							
						
					
					
						commit
						39cdba9f90
					
				
					 15 changed files with 67 additions and 51 deletions
				
			
		| 
						 | 
				
			
			@ -17,7 +17,6 @@ const createRoom = sync.require("../actions/create-room")
 | 
			
		|||
async function addReaction(data) {
 | 
			
		||||
   const user = data.member?.user
 | 
			
		||||
   assert.ok(user && user.username)
 | 
			
		||||
   // TODO: should add my own sent messages to event_message so they can be reacted to?
 | 
			
		||||
   const parentID = db.prepare("SELECT event_id FROM event_message WHERE message_id = ? AND part = 0").pluck().get(data.message_id) // 0 = primary
 | 
			
		||||
   if (!parentID) return // TODO: how to handle reactions for unbridged messages? is there anything I can do?
 | 
			
		||||
   assert.equal(typeof parentID, "string")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ async function sendMessage(message, guild) {
 | 
			
		|||
		delete eventWithoutType.$type
 | 
			
		||||
 | 
			
		||||
		const eventID = await api.sendEvent(roomID, eventType, event, senderMxid)
 | 
			
		||||
		db.prepare("INSERT INTO event_message (event_id, message_id, part) VALUES (?, ?, ?)").run(eventID, message.id, eventPart)
 | 
			
		||||
		db.prepare("INSERT INTO event_message (event_id, message_id, part, source) VALUES (?, ?, ?, 1)").run(eventID, message.id, eventPart) // source 1 = discord
 | 
			
		||||
 | 
			
		||||
		eventPart = 1 // TODO: use more intelligent algorithm to determine whether primary or supporting
 | 
			
		||||
		eventIDs.push(eventID)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue