Skip to content

Commit

Permalink
/zoom start slash command posts in thread (#228)
Browse files Browse the repository at this point in the history
Co-authored-by: Maisnam Raju Singh <[email protected]>
  • Loading branch information
sanjaydemansol and maisnamrajusingh authored Dec 7, 2021
1 parent 655befa commit bb036f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (p *Plugin) runStartCommand(args *model.CommandArgs, user *model.User, topi
}

if recentMeeting {
p.postConfirm(recentMeetingLink, args.ChannelId, topic, user.Id, creatorName, provider)
p.postConfirm(recentMeetingLink, args.ChannelId, topic, user.Id, args.RootId, creatorName, provider)
return "", nil
}

Expand All @@ -136,7 +136,7 @@ func (p *Plugin) runStartCommand(args *model.CommandArgs, user *model.User, topi
return authErr.Message, authErr.Err
}

if err := p.postMeeting(user, zoomUser.Pmi, args.ChannelId, topic); err != nil {
if err := p.postMeeting(user, zoomUser.Pmi, args.ChannelId, args.RootId, topic); err != nil {
return "Failed to post message. Please try again.", nil
}

Expand Down
12 changes: 7 additions & 5 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (p *Plugin) completeUserOAuthToZoom(w http.ResponseWriter, r *http.Request)

if justConnect {
p.postEphemeral(userID, channelID, "Successfully connected to Zoom")
} else if err = p.postMeeting(user, zoomUser.Pmi, channelID, ""); err != nil {
} else if err = p.postMeeting(user, zoomUser.Pmi, channelID, "", ""); err != nil {
p.API.LogWarn("Failed to post meeting", "error", err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down Expand Up @@ -296,7 +296,7 @@ func (p *Plugin) handleMeetingEnded(w http.ResponseWriter, r *http.Request, webh
}
}

func (p *Plugin) postMeeting(creator *model.User, meetingID int, channelID string, topic string) error {
func (p *Plugin) postMeeting(creator *model.User, meetingID int, channelID string, rootID string, topic string) error {
meetingURL := p.getMeetingURL(creator, meetingID)

if topic == "" {
Expand All @@ -316,6 +316,7 @@ func (p *Plugin) postMeeting(creator *model.User, meetingID int, channelID strin
post := &model.Post{
UserId: creator.Id,
ChannelId: channelID,
RootId: rootID,
Message: "I have started a meeting",
Type: "custom_zoom",
Props: map[string]interface{}{
Expand Down Expand Up @@ -379,7 +380,7 @@ func (p *Plugin) handleStartMeeting(w http.ResponseWriter, r *http.Request) {
if err != nil {
p.API.LogWarn("failed to write response", "error", err.Error())
}
p.postConfirm(recentMeetingLink, req.ChannelID, req.Topic, userID, creatorName, provider)
p.postConfirm(recentMeetingLink, req.ChannelID, req.Topic, userID, "", creatorName, provider)
return
}
}
Expand All @@ -401,7 +402,7 @@ func (p *Plugin) handleStartMeeting(w http.ResponseWriter, r *http.Request) {
}

meetingID := zoomUser.Pmi
if err = p.postMeeting(user, meetingID, req.ChannelID, req.Topic); err != nil {
if err = p.postMeeting(user, meetingID, req.ChannelID, "", req.Topic); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
Expand Down Expand Up @@ -435,7 +436,7 @@ func (p *Plugin) getMeetingURL(user *model.User, meetingID int) string {
return meeting.JoinURL
}

func (p *Plugin) postConfirm(meetingLink string, channelID string, topic string, userID string, creatorName string, provider string) *model.Post {
func (p *Plugin) postConfirm(meetingLink string, channelID string, topic string, userID string, rootID string, creatorName string, provider string) *model.Post {
message := "There is another recent meeting created on this channel."
if provider != zoomProviderName {
message = fmt.Sprintf("There is another recent meeting created on this channel with %s.", provider)
Expand All @@ -444,6 +445,7 @@ func (p *Plugin) postConfirm(meetingLink string, channelID string, topic string,
post := &model.Post{
UserId: p.botUserID,
ChannelId: channelID,
RootId: rootID,
Message: message,
Type: "custom_zoom",
Props: map[string]interface{}{
Expand Down

0 comments on commit bb036f8

Please sign in to comment.