Skip to content

Commit

Permalink
[MM-54520] Soft fail in case of missing post during state cleanup (#530)
Browse files Browse the repository at this point in the history
* Soft fail in case of missing post during state cleanup

* Add validity check on postID
  • Loading branch information
streamer45 authored and cpoile committed Oct 2, 2023
1 parent 7572160 commit 420af18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/channel_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (p *Plugin) cleanCallState(channelID string, state *channelState) error {

if state.Call != nil {
if _, err := p.updateCallPostEnded(state.Call.PostID, mapKeys(state.Call.Stats.Participants)); err != nil {
return err
p.LogError("failed to update call post", "err", err.Error())
}
state.Call = nil
}
Expand Down
4 changes: 4 additions & 0 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ func (p *Plugin) createCallStartedPost(state *channelState, userID, channelID, t
}

func (p *Plugin) updateCallPostEnded(postID string, participants []string) (float64, error) {
if postID == "" {
return 0, fmt.Errorf("postID should not be empty")
}

post, appErr := p.API.GetPost(postID)
if appErr != nil {
return 0, appErr
Expand Down

0 comments on commit 420af18

Please sign in to comment.