Skip to content

Instantly share code, notes, and snippets.

@xNok
Created April 8, 2021 01:35
Show Gist options
  • Save xNok/dc5a391cfdc66d70c53159e05afc49b2 to your computer and use it in GitHub Desktop.
Save xNok/dc5a391cfdc66d70c53159e05afc49b2 to your computer and use it in GitHub Desktop.
func (c *AppHomeController) createStickieNote(evt *socketmode.Event, clt *socketmode.Client) {
// we need to cast our socketmode.Event into slack.InteractionCallback
view_submission := evt.Data.(slack.InteractionCallback)
// Make sure to respond to the server to avoid an error
clt.Ack(*evt.Request)
// Create the model
note := views.StickieNote{
Description: view_submission.View.State.Values[views.ModalDescriptionBlockID][views.ModalDescriptionActionID].Value,
Color: view_submission.View.State.Values[views.ModalColorBlockID][views.ModalColorActionID].SelectedOption.Value,
Timestamp: time.Unix(time.Now().Unix(), 0).String(),
}
// create the view using block-kit
view := views.AppHomeCreateStickieNote(note)
// Publish the view (23)
// We get the Api client from `clt` and post our view
_, err := clt.GetApiClient().PublishView(view_submission.User.ID, view, "")
//Handle errors
if err != nil {
log.Printf("ERROR createStickieNote: %v", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment