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

feat: Add MatterMost remote #508

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JamesMConroy
Copy link

@JamesMConroy JamesMConroy commented May 3, 2024

Proposed change

Adds a basic mattermost remote to handle receiving webhook events and posting messages with the API.

Should resolve #97

Types of changes

What types of changes is this pull request introducing to flottbot? Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

You can fill this out after creating your PR. Put an x in the boxes that apply

  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Testing

To test I used the docker image and add user script from the MM bot example repo https://github.com/mattermost-community/mattermost-bot-sample-golang

Adds a basic mattermost remote to handle recieving webhook events and
posting messages with the API.
@wass3rw3rk
Copy link
Member

thanks for the PR and apologies for the delay, i will give it a look in the coming days. also, looking to test it on a real or fake mattermost instance

@JamesMConroy
Copy link
Author

No worries @wass3rw3rk stuff happens and I've had PRs sit idle for longer.

This did work with that local mattermost development container, but it didn't work with my company's MatterMost.

We use the version packaged with Gitlab Omnibus and it's a pain to test against because it is in a sandbox environment.

I don't know if it is our configuration or an issue with how I'm using the websocket library, but I would get a panic when trying to connect.

Copy link
Member

@wass3rw3rk wass3rw3rk left a comment

Choose a reason for hiding this comment

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

I got a local version of Mattermost stood up with Docker and things worked pretty well. A couple of notes below.

Thanks again for the patience.

// instantiate a new mattermost client.
func (c *Client) new() *model.Client4 {
log.Info().Msgf("%#v", c)
api := model.NewAPIv4Client("http://" + c.Server)
Copy link
Member

Choose a reason for hiding this comment

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

presumably server is not typically on http but https? should the expectation be to provide a FQDN for the MATTERMOST_SERVER configuration item?

Copy link
Author

Choose a reason for hiding this comment

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

Yea, it probably should default to https.

I'd like to keep the ability to set MATTERMOST_SERVER as a bare IP address, if for no other reason than testing.

What's the best way to allow the user to connect over http if that's what they want? An optional MATTERMOST_SECURE_PROTOCOL variable or something like that?

Copy link
Member

Choose a reason for hiding this comment

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

i think i would default to secure: https + wss and add a flag like you said. maybe inverse though, something like MATTERMOST_USE_INSECURE or MATTERMOST_LOCAL? not sure if local is the only use-case, so maybe the former?

c.BotID = user.Username
}

sock, err := model.NewWebSocketClient4("ws://"+c.Server, c.Token)
Copy link
Member

Choose a reason for hiding this comment

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

Similar to previous comment, I presume this would be wss: for most installations?

Copy link
Author

Choose a reason for hiding this comment

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

Yep I'll update that. It might be the issue I'm seeing with my work instance.

Comment on lines +13 to +15
MATTERMOST_CHANNEL=
MATTERMOST_USERNAME=
Copy link
Member

Choose a reason for hiding this comment

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

these seem to be unused? is this for future work?

Copy link
Author

Choose a reason for hiding this comment

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

I think I added them expecting them to be needed but never got around to using them. They might be nice in the future, but I'll remove them until/unless I find a need.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good - thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Mattermost as a remote?
2 participants