Skip to content

Commit

Permalink
[MI-1996]: Resolved the bug in use PMI feature of zoom plugin
Browse files Browse the repository at this point in the history
1. Resolved the problem of  500 internal server error which we were getting on clicking create new meeting when our use PMI was set to ask
2. Added c.apiURL in URL
3. Added auto suggestion for use PMI
  • Loading branch information
Nityanand13 committed Aug 3, 2022
1 parent ba74224 commit a80b373
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 7 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Continuous Integration Workflow to check pushes to master and pull requests:
# - code style guidelines are followed (make check-style)
# - tests pass (make test)
# - code builds (make dist)
name: CI

on:
pull_request:
push:
branches:
- master

jobs:
ci:
name: Check style; build; test
runs-on: ubuntu-latest

steps:
- name: Set up Go v1.16.x
uses: actions/setup-go@v2
with:
go-version: 1.16.x

- name: Set up Node.js v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
registry-url: https://npm.pkg.github.com/

- name: Install golangci
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.36.0

- uses: actions/checkout@v2

- name: Cache go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install webapp dependencies
run: make webapp/node_modules
env:
TERM: dumb

- name: check style
run: make check-style
env:
TERM: dumb

- name: run tests
run: make test
env:
TERM: dumb

- name: Build and bundle the plugin
id: build
run: |
make dist
echo ::set-output name=BUNDLE_NAME::$(cd dist; ls *.tar.gz)
env:
TERM: dumb

- name: Upload the built plugin as an artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build.outputs.BUNDLE_NAME }}
path: dist/${{ steps.build.outputs.BUNDLE_NAME }}
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build_and_release:
name: Build and release
runs-on: ubuntu-latest
steps:
- name: Set up Go v1.16.x
uses: actions/setup-go@v2
with:
go-version: 1.16.x

- name: Set up Node.js v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
registry-url: https://npm.pkg.github.com/

- uses: actions/checkout@v2

- name: Cache go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build and bundle the plugin
id: build
run: |
make dist
echo ::set-output name=BUNDLE_NAME::$(cd dist; ls *.tar.gz)
env:
TERM: dumb

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ steps.build.outputs.BUNDLE_NAME }}
asset_name: ${{ steps.build.outputs.BUNDLE_NAME }}
asset_content_type: application/gzip
28 changes: 23 additions & 5 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
helpText = `* |/zoom start| - Start a zoom meeting`
oAuthHelpText = `* |/zoom disconnect| - Disconnect from zoom`
settingHelpText = `* |/zoom setting| - Configure setting options`
settingPMIHelpText = `* |/zoom setting usePMI [true/false/ask]| -
settingPMIHelpText = `* |/zoom setting use_pmi [true/false/ask]| -
enable / disable / undecide to use PMI to create meeting
`
alreadyConnectedString = "Already connected"
Expand Down Expand Up @@ -146,6 +146,9 @@ func (p *Plugin) runStartCommand(args *model.CommandArgs, user *model.User) (str
} else {
p.askUserPMIMeeting(user.Id, args.ChannelId)
}
if meetingID == -1 && createMeetingErr == nil {
return "", nil
}
if meetingID <= 0 || createMeetingErr != nil {
return "", errors.New("error while create new meeting")
}
Expand Down Expand Up @@ -222,15 +225,15 @@ func (p *Plugin) runHelpCommand() (string, error) {
return text, nil
}

// run "/zoom setting" command, e.g: /zoom setting usePMI true
// run "/zoom setting" command, e.g: /zoom setting use_pmi true
func (p *Plugin) runSettingCommand(settingCommands []string, user *model.User) (string, error) {
settingAction := ""
if len(settingCommands) > 0 {
settingAction = settingCommands[0]
}
switch settingAction {
case "usePMI":
// here process the usePMI command
case "use_pmi":
// here process the use_pmi command
if len(settingCommands) > 1 {
return p.runPMISettingCommand(settingCommands[1], user)
}
Expand All @@ -255,7 +258,7 @@ func (p *Plugin) runPMISettingCommand(usePMIValue string, user *model.User) (str
}); appError != nil {
return "Cannot update preference in zoom setting", nil
}
return fmt.Sprintf("Update successfully, usePMI: %v", usePMIValue), nil
return fmt.Sprintf("Update successfully, use_pmi: %v", usePMIValue), nil
default:
return fmt.Sprintf("Unknown setting option %v", usePMIValue), nil
}
Expand All @@ -282,6 +285,21 @@ func (p *Plugin) getAutocompleteData() *model.AutocompleteData {
// setting
setting := model.NewAutocompleteData("setting", "[command]", "Configurates options")
zoom.AddCommand(setting)

// usePMI
usePMI := model.NewAutocompleteData("use_pmi", "", "Use Personal Meeting ID")
usePMIItems := []model.AutocompleteListItem{{
HelpText: "Ask to start meeting with PMI or without Personal Meeting ID",
Item: "ask",
}, {
HelpText: "Start meeting with Personal Meeting ID",
Item: "true",
}, {
HelpText: "Start meeting without Personal Meeting ID",
Item: "false",
}}
usePMI.AddStaticListArgument("", false, usePMIItems)
setting.AddCommand(usePMI)
// help
help := model.NewAutocompleteData("help", "", "Display usage")
zoom.AddCommand(help)
Expand Down
4 changes: 4 additions & 0 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ func (p *Plugin) handleStartMeeting(w http.ResponseWriter, r *http.Request) {
meetingID, createMeetingErr = p.createMeetingWithoutPMI(user, zoomUser, req.ChannelID, topic)
}

if meetingID == -1 && createMeetingErr == nil {
return
}

if meetingID >= 0 && createMeetingErr == nil {
if err = p.postMeeting(user, meetingID, req.ChannelID, topic); err == nil {
meetingURL := p.getMeetingURL(user, meetingID)
Expand Down
2 changes: 1 addition & 1 deletion server/zoom/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (c *OAuthClient) CreateMeeting(user *User, topic string) (*Meeting, error)
return nil, err
}

res, err := client.Post(fmt.Sprintf("/users/%s/meetings", user.Email), "application/json", bytes.NewReader(b))
res, err := client.Post(fmt.Sprintf("%s/users/%s/meetings", c.apiURL, user.Email), "application/json", bytes.NewReader(b))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const doPost = async (url, body, headers = {}) => {
const response = await fetch(url, Client4.getOptions(options));

if (response.ok) {
return response.json();
return response.text();
}

const text = await response.text();
Expand Down

0 comments on commit a80b373

Please sign in to comment.