calpoly-csai / groupme-bot

a bot to automate stuff when GroupMe messages are received
https://calpoly-csai-groupme-bot.herokuapp.com
GNU General Public License v3.0
0 stars 3 forks source link

Duplicate messages should not happen #7

Open mfekadu opened 4 years ago

mfekadu commented 4 years ago

How does it happen?

With the CSAI GroupMe

  1. open your browser
  2. navigate to https://calpoly-csai-groupme-bot.herokuapp.com/new-groupme-message
  3. refresh the page
  4. open the Slack page
  5. notice the duplicate messages

With the NSBE GroupMe

  1. open your browser
  2. navigate to https://calpoly-slo-nsbe-groupme-bot.herokuapp.com/new-groupme-message
  3. refresh the page
  4. open the Slack page
  5. notice the duplicate messages

screenshot

image

Possible solutions

1. append the message id to the carried over slack message. Then later we can check if a new message has already been posted to slack by looking at the last 10 or so messages.

Here is the JSON given by GroupMe

{
    "attachments": [],
    "avatar_url": "https://i.groupme.com/1383x1383.png.7da0a3caddbc47b4948c6b4e8103f217",
    "created_at": 1585440279,
    "favorited_by": ["31476105"],
    "group_id": "49802741",
    "id": "158544027923017552",
    "name": "Michael Fekadu",
    "platform": "gm",
    "sender_id": "5943680",
    "sender_type": "user",
    "source_guid": "b63c669fdad122a86cfb8601eb69f4f6",
    "system": false,
    "text": "So this message, ideally, should be carried over into Slack as well. Assuming no bugs of course. If it works, please do regard :)",
    "user_id": "5943680"
}

2. maybe cache the messages or the message ids locally

3. or do #1 except just do a full string comparison of the last 10 or so messages with the most recent one

chidiewenike commented 4 years ago

I think Solution 1 would be the most efficient but not as aesthetically pleasing as Solution 3. What do you think of the trade-off @mfekadu ?