Skip to content

Commit

Permalink
Fixed bug in cc-func-openthread (#1703)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashish Jhanwar <[email protected]>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Jul 16, 2024
1 parent 2ca6120 commit 23a19ae
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions common/templates/context_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1220,13 +1220,13 @@ func (c *Context) tmplOpenThread(channel interface{}) (string, error) {
return "", ErrTooManyCalls
}

cstate := c.GS.GetChannelOrThread(cID)
if cstate == nil {
return "", errors.New("thread not in state")
thread, err := common.BotSession.Channel(cID)
if err != nil || thread == nil {
return "", errors.New("unable to get thread")
}

if !cstate.Type.IsThread() {
return "", errors.New("must specify a thread")
if !thread.Type.IsThread() {
return "", errors.New("not a thread")
}

falseVar := false
Expand All @@ -1235,7 +1235,7 @@ func (c *Context) tmplOpenThread(channel interface{}) (string, error) {
Locked: &falseVar,
}

_, err := common.BotSession.ChannelEditComplex(cID, edit)
_, err = common.BotSession.ChannelEditComplex(cID, edit)
if err != nil {
return "", errors.New("unable to edit thread")
}
Expand Down

0 comments on commit 23a19ae

Please sign in to comment.