Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp with latest driver, bot account support & more #43

Merged
merged 2 commits into from
Jun 5, 2023

Conversation

IceWreck
Copy link
Contributor

Summary

  • Use the latest release of mattermost-server and switch to newer Go APIs (most of the Go functions used before have different signatures or been removed entirely in newer versions of mattermost-server)
  • Use bot accounts / token instead of user account
  • Cleaner and more structured code
  • Don't panic when connection closes unexpectedly (when mattermost server dies or bot get disconnected )
  • No global variables
  • Use env vars or .env file for configuration
  • Level based logging
  • Do not wait for one message to be handled before moving to next
  • Example to reply in an existing thread

BTW, is there a reason that latest tagged version of mattermost-server on go.dev is 6.7.X (from afew months ago) instead of Mattermost 7.1 (which is latest according to github releases) ?

Ticket Link

Solves #30 and more

@mattermost-build
Copy link

Hello @IceWreck,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

- Use the latest release of mattermost-server
  and switch to newer Go APIs
- Use bot accounts / token instead of user account
- Cleaner and more structured code
- Don't panic when connection closes unexpectedly
  (when mattermost server dies or bot get disconnected )
- No global variables
- Use env vars or .env file for configuration
- Level based logging
- Do not wait for one message to be handled before moving to next
- Example to reply in an existing thread
Copy link

@m1lt0n m1lt0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR @IceWreck ! I have added myself and Martin as reviewers.

I've left a few comments (mainly in the README file and the db seeding script that creates initial users) and tested locally the PR and confirm it works as expected.

Thanks for the PR again!

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
example.env Outdated Show resolved Hide resolved
@m1lt0n m1lt0n requested a review from catalintomai January 13, 2023 14:32
@hanzei hanzei added the Triage label Jan 23, 2023
failCount := 0
for {
app.mattermostWebSocketClient, err = model.NewWebSocketClient4(
fmt.Sprintf("ws://%s", app.config.mattermostServer.Host+app.config.mattermostServer.Path),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is a better best practice to use wss (Web Socket Secure) by default? https://www.rfc-editor.org/rfc/rfc6455#page-55

Copy link
Contributor Author

@IceWreck IceWreck Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone doing bot development with the docker-compose in this repo won't have SSL on their local instance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could parse the Mattermost server URL and determine whether we are using http or https, and adjust the websocket protocol accordingly

@mattermost-build
Copy link

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@mickmister mickmister removed the Triage label Feb 27, 2023
@catalintomai catalintomai removed their request for review February 28, 2023 12:45
@hanzei hanzei requested a review from crspeller May 21, 2023 20:43
@hanzei hanzei added 2: Dev Review Requires review by a core committer and removed Lifecycle/1:stale labels May 21, 2023
@mattermost-build
Copy link

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

Copy link
Contributor

@crspeller crspeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@crspeller crspeller merged commit a715fa2 into mattermost-community:master Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants