Closed earlduque closed 1 year ago
Hey Earl,
I haven't been able to generate a message that doesn't have the .user or (unlikely) the .event object, would you be able to search for
sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^payloadNOT LIKE"user":
on the payload table and give us some examples I can work with, if that's OK? We can test for the missing attribute easily enough, but being able to assess the model would make sure we can have a more permanent solution validated.
Ok, found it. Slack has a couple of message payload formats that won't have the user property directly within the event object. The most likely trigger is message_changed (people updating their messages).
The payloads that don't work have the subtype property under event, and only the following subtypes change format:
Test for the user or subtype property and if present, test the subtype and change where you draw slackID from respectively
var userSlackID, message = JSON.parse(current.payload);
if (current.event.hasOwnProperty('subtype') && (current.event.subtype === "message_changed" /* || current.event.subtype === "message_replied" */)) {
userSlackID = message.event.message.user.replace(/<@/g,"").replace(/>/g,"");
}
userSlackID = message.event.user.replace(/<@/g,"").replace(/>/g,"");
Implementing that would mean we would support points on edit, which could add a chance to be gamed (although we could report on that, or set limits).
Alternatively we could add checks for it, and then return without inserting the chats so we avoid the error and triggering actions off the chats. Would be interested for input on preferences for how we implement that?
Thanks @SapphicFire for the findings, thank you for figuring it out. I added a an ignore on the scripted rest api, the payload is no longer created on message_changed
events
if (request.body.data.event.bot_id || request.body.data.event.subtype == 'message_changed') return;
:ohno: this will break trebek not firing multiple times because that was relying on the message_changed event from the image unfurling.
but... that was a hack anyway 😄
I think we should store/process request.body.data.event.bot_id
so we can see if/when the bot last posted a message but that'd require updates to basically ignore them in all other instances.
perhaps adding a u_is_bot
on the user record and not firing if the message was from a bot?
This shouldn't have any bearing on trebek since we're talking PointsThing not Slacker 😜
you got TOLD @chelming 🔥
nothing_to_see_here.gif
unsure of what is causing it