Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the slack platform support #71

Merged
merged 23 commits into from
Feb 28, 2023
Prev Previous commit
Next Next commit
resolved
ash0521 committed Feb 23, 2023
commit f21f5295264def738b37dc690c901ca7a4574965
8 changes: 7 additions & 1 deletion validator/slack/slack.go
Original file line number Diff line number Diff line change
@@ -107,11 +107,16 @@ func (slack *Slack) Validate() (err error) {
if err != nil {
return xerrors.Errorf("Error when parsing slack message ID %s: %s", slack.ProofLocation, err.Error())
}

maxPages := 10 // maximum number of pages to fetch
pageCount := 0
var foundMsg *slackClient.Message
var latestTs string

for {
if pageCount >= maxPages {
return xerrors.Errorf("Reached max number of pages (%d) while searching for message with ID %d in conversation history", maxPages, messageID)
}

// Get conversation history
history, err := client.GetConversationHistory(&slackClient.GetConversationHistoryParameters{
ChannelID: channelID,
@@ -140,6 +145,7 @@ func (slack *Slack) Validate() (err error) {
}

latestTs = history.Messages[len(history.Messages)-1].Timestamp
pageCount++
}

userInt, err := strconv.ParseInt(foundMsg.User, 10, 64)