bettersg / checkMate

GNU General Public License v3.0
5 stars 0 forks source link

Double votes being created for messages, if user sends in identical messages in quick succession #359

Closed sarge1989 closed 1 week ago

sarge1989 commented 1 week ago

Happens because in onInstanceCreate

if (
        parentInstanceCount >= thresholds.startVote &&
        !parentMessageSnap.get("isPollStarted")
      ) {
        await triggerAgents(snap)
        await despatchPoll(parentMessageRef)
        return parentMessageRef.update({ isPollStarted: true })
}

The isPollStarted is only updated at the end of despatchPoll, which means if messages come before despatchPoll ends, another round is fired off.