Rocket.Chat.Apps-engine icon indicating copy to clipboard operation
Rocket.Chat.Apps-engine copied to clipboard

Add listeners for set and unset reaction

Open sampaiodiego opened this issue 6 years ago • 7 comments

Some might want to do something when people add or remove a reaction from a message

sampaiodiego avatar Feb 18 '19 17:02 sampaiodiego

Maybe some message_editted hooks? We could send the changelog for the message to the app (along with the message itself, of course)

d-gubert avatar Feb 18 '19 20:02 d-gubert

should a reaction trigger a message_edited hook?

I also wonder about Apps permission. A permission to listen for reaction is way less intrusive than message edits.

sampaiodiego avatar Feb 18 '19 20:02 sampaiodiego

should a reaction trigger a message_edited hook?

I do think they fit in the same event type.

I also wonder about Apps permission. A permission to listen for reaction is way less intrusive than message edits.

Do we want to go for that granular control over permissions, though? I think we might over-complicate things for end-users if we create a permission item for every possible variation on a point of interaction an app may have; also, that would make developers' lives harder, having to understand the definition of permissions that look similar (one example being extending a message vs destructively modifying a message IMO)

Which brings us to the question: is it time for us to start discussing permissions on the forum?

d-gubert avatar Feb 18 '19 21:02 d-gubert

@rodrigok me and @sampaiodiego have disagreed on this matter, we need another opinion to break the tie :stuck_out_tongue:

d-gubert avatar Feb 26 '19 15:02 d-gubert

it's possible a return with a value as an added or removed reaction example:

added reaction:

 { _id: 'CGRxi7SpCEJgEA63t',
  rid: 'GENERAL',
  msg: 'aaa',
  ts: { '$date': 1551396092029 },
  u:
   { _id: '2BQ3wWnRBh7vXGYdP',
     username: 'eduardo.junior',
     name: 'Eduardo Junior' },
  _updatedAt: { '$date': 1551396149410 },
  mentions: [],
  channels: [],
  reactions: { 
     'kind': 'reaction_added',
     ':thumbsup:': { usernames: [Array] } },
  origin: 'rocket' } { roomParticipant: true, roomType: 'c', roomName: 'general' }

removed reaction:

 { _id: 'CGRxi7SpCEJgEA63t',
  rid: 'GENERAL',
  msg: 'aaa',
  ts: { '$date': 1551396092029 },
  u:
   { _id: '2BQ3wWnRBh7vXGYdP',
     username: 'eduardo.junior',
     name: 'Eduardo Junior' },
  _updatedAt: { '$date': 1551396149410 },
  mentions: [],
  channels: [],
  reactions: { 
     'kind': 'reaction_removed',
     ':thumbsup:': { usernames: [Array] } },
  origin: 'rocket' } { roomParticipant: true, roomType: 'c', roomName: 'general' }

goldblade avatar Feb 28 '19 23:02 goldblade

@d-gubert we might want to make something extremely simple that is like onMessageReactionAdd and onMessageReactionRemove that passes in the room, message, user, and reaction which was added or removed. I think it doesn't over complicate things for users. Since reactions currently don't fire a "message updated" event, then us adding this allows for developers of Apps to easily listen and only care about it. This is my opinion and probably how I would implement it, to be honest.

As it kind of flows with the "scopes" limiting and us later being able to programmatically tell what an app listens to and show that to users of the apps since they would be implementing an interface.

graywolf336 avatar Apr 25 '19 19:04 graywolf336

That would be a big improvement for building interactive applications. Dedicated events for reactions would be very helpful.

tjaeger1 avatar Nov 12 '20 13:11 tjaeger1