-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
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. |
There was a problem hiding this 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.
.../org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotificationTest.java
Outdated
Show resolved
Hide resolved
.../org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotificationTest.java
Outdated
Show resolved
Hide resolved
.../org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotificationTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
There was a problem hiding this 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.
...java/org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotification.java
Outdated
Show resolved
Hide resolved
...java/org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotification.java
Outdated
Show resolved
Hide resolved
.../org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotificationTest.java
Outdated
Show resolved
Hide resolved
.../org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotificationTest.java
Outdated
Show resolved
Hide resolved
.../org/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotificationTest.java
Outdated
Show resolved
Hide resolved
return new AutoValue_TeamsEventNotificationConfig.Builder() | ||
.type(TYPE_NAME) | ||
.color(DEFAULT_HEX_COLOR) | ||
.webhookUrl(WEB_HOOK_URL) | ||
.customMessage(DEFAULT_CUSTOM_MESSAGE) | ||
.backlogSize(DEFAULT_BACKLOG_SIZE); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
...rg/graylog/integrations/notifications/types/microsoftteams/TeamsEventNotificationConfig.java
Show resolved
Hide resolved
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class TeamsMessage { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Line 33 in ac5718a
public class SlackMessage { |
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Dismissing because I might be out tomorrow.
Microsoft Teams Notification Co-authored-by: S srinidhi <[email protected]> Co-authored-by: Dan Torrey <[email protected]>
Microsoft Teams Notification Co-authored-by: S srinidhi <[email protected]> Co-authored-by: Dan Torrey <[email protected]>
Microsoft Teams Notification Co-authored-by: S srinidhi <[email protected]> Co-authored-by: Dan Torrey <[email protected]>
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