Fix topic set after channel creation
This commit is contained in:
parent
dd0cab8a9d
commit
b6777746e4
15
update.go
15
update.go
@ -437,17 +437,22 @@ func CreateSlackChannels() {
|
|||||||
|
|
||||||
// If topic is defined, set the topic and purpose.
|
// If topic is defined, set the topic and purpose.
|
||||||
if topic != "" {
|
if topic != "" {
|
||||||
// Sleep before, as it takes time for Slack APIs
|
// Keep count of failures so we can try again.
|
||||||
// to recongize the channel was created.
|
failed := 0
|
||||||
time.Sleep(120 * time.Second)
|
_, err = app.slack.SetTopicOfConversation(schan.ID, topic)
|
||||||
_, err = app.slack.SetTopicOfConversation(channel.ID, topic)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
failed++
|
||||||
log.Println("Failed to set topic:", err)
|
log.Println("Failed to set topic:", err)
|
||||||
}
|
}
|
||||||
_, err = app.slack.SetPurposeOfConversation(channel.ID, topic)
|
_, err = app.slack.SetPurposeOfConversation(schan.ID, topic)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
failed++
|
||||||
log.Println("Failed to set purpose:", err)
|
log.Println("Failed to set purpose:", err)
|
||||||
}
|
}
|
||||||
|
// If it failed, make topic empty so we can try again next run.
|
||||||
|
if failed != 0 {
|
||||||
|
topic = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the channel to the database.
|
// Save the channel to the database.
|
||||||
|
Loading…
Reference in New Issue
Block a user