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

Microsoft Teams Notification #1064

Merged
merged 15 commits into from
Jun 14, 2022
Merged

Conversation

kingzacko1
Copy link
Contributor

@kingzacko1 kingzacko1 commented Jun 13, 2022

Notes for Reviewers

this is a new PR from the existing PR #962. The latest commits have code cleanup and address PR feedback from the original PR.

  • Created Microsoft Teams Notification Plugin.

  • Moved HttpClient request to util package which is a common file

  • The commit history must be preserved - please use the rebase-merge or standard merge option instead of squash-merge

  • Sync up with the author before merging

@CLAassistant
Copy link

CLAassistant commented Jun 13, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ danotorrey
✅ kingzacko1
❌ S srinidhi


S srinidhi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

@mikedklein mikedklein left a comment

Choose a reason for hiding this comment

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

LGTM. I can't test the functionality as I am not on AD. But the front-end linting fixes all look correct.

@kingzacko1 kingzacko1 mentioned this pull request Jun 13, 2022
2 tasks
Copy link
Contributor

@ryan-carroll-graylog ryan-carroll-graylog left a comment

Choose a reason for hiding this comment

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

Looks good other than some commented out code in a couple unit tests. Tested the functionality and everything seems to be working.

Copy link
Contributor

@roberto-graylog roberto-graylog left a comment

Choose a reason for hiding this comment

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

Looks good over all. It seem I missed a class field that could be a local variable (I think) in class TeamsEventNotification. If this class is to be instantiated for every execution, then it may be not be an issue.

Comment on lines +119 to +125
return new AutoValue_TeamsEventNotificationConfig.Builder()
.type(TYPE_NAME)
.color(DEFAULT_HEX_COLOR)
.webhookUrl(WEB_HOOK_URL)
.customMessage(DEFAULT_CUSTOM_MESSAGE)
.backlogSize(DEFAULT_BACKLOG_SIZE);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The webhook URL and custom message defaults do not appear to be shown in the UI for new notifications. Do you know why this seems to be happening? The color appears to show.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default values for the UI are set in the frontend code. See TeamsNotificationForm.tsx

import java.util.List;
import java.util.Map;

public class TeamsMessage {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a simple POJO that maps the Java object to JSON. In most of the Graylog codebase, that is done with AutoValue classes (with annotated fields and create or builder methods) and Jackson and not with constructor-driven POJOs that have built-in serialization logic (see the getJsonString() method).

For consistency with the most of the pre-existing codebase, I suggest that we should use an AutoValue object instead, and post that directly with the OkHttp client and let the conversion to JSON happen implicitly, or manually convert it using Jackson.

Here is an example:
https://github.com/Graylog2/graylog-plugin-enterprise/blob/72b5428c61cffe7c483e2363322222abc1701105/enterprise/src/main/java/org/graylog/plugins/license/LicenseReportPeriodical.java#L122-L143

Copy link
Contributor

Choose a reason for hiding this comment

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

Now I am seeing that this was previously established in the Slack notification.

I am fine with merging this PR as-is, but I think this should be refactored in a subsequent PR for consistency if possible. I think it would be best to avoid replicating this pattern, unless there is a reason for it I am not seeing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree we can merge as is but then work a minor task to refactor this and the SlackMessage POJO to an AutoValue based class instead of the current implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kingzacko1 and I discussed that this fits well in a separate PR after this is merged. It will be easier to review that way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding this here as because we're discussing a separate PR involving Slack: Webhook validation for Slack doesn't appear to working. I was able to (accidently) use a Teams webhook url in a Slack Graylog Notification, and receive a message in Microsoft Teams.

@danotorrey danotorrey dismissed their stale review June 13, 2022 21:15

Dismissing because I might be out tomorrow.

@kingzacko1 kingzacko1 merged commit 07ca26e into master Jun 14, 2022
@kingzacko1 kingzacko1 deleted the feature/microsoft-teams-notification branch June 14, 2022 14:24
kingzacko1 added a commit that referenced this pull request Jun 14, 2022
Microsoft Teams Notification

Co-authored-by: S srinidhi <[email protected]>
Co-authored-by: Dan Torrey <[email protected]>
kingzacko1 added a commit that referenced this pull request Jun 14, 2022
Microsoft Teams Notification

Co-authored-by: S srinidhi <[email protected]>
Co-authored-by: Dan Torrey <[email protected]>
dennisoelkers pushed a commit to Graylog2/graylog2-server that referenced this pull request Aug 29, 2023
Microsoft Teams Notification

Co-authored-by: S srinidhi <[email protected]>
Co-authored-by: Dan Torrey <[email protected]>
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.

7 participants