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
fix: moving slack integration to ee module & improvements #2301
base: slack-integration
Are you sure you want to change the base?
fix: moving slack integration to ee module & improvements #2301
Conversation
huglx
commented
May 10, 2024
- move controllers & business logic to ee module
- add slack integration to features
…t authors of changes, but also by past ones
…hosov/slack-integration-ee-feature-restrictions
add more updates:
|
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.
Let's merge it after the fixes, but please add more tests testing these changes in next iteration.
import org.hibernate.annotations.Type | ||
|
||
@Entity | ||
class SavedSlackMessage( | ||
val messageTs: String, | ||
val messageTs: String = "", |
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.
What is Ts? Please don't use abbreviations, if it's not 100% obvious.
var langTags: Set<String>, | ||
var createdKeyBlocks: Boolean, | ||
) : StandardAuditModel() | ||
var langTags: Set<String> = setOf(), |
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.
var langTags: Set<String> = setOf(), | |
var languageTags: Set<String> = setOf(), |
import org.hibernate.annotations.ColumnDefault | ||
import org.hibernate.annotations.Type | ||
|
||
@Entity | ||
class SlackConfig( | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
var project: Project, | ||
var project: Project = Project(), |
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.
Don't set defaults in entity constructors like this, it is unsafe...
@Entity | ||
class SlackMessageInfo( | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
var slackMessage: SavedSlackMessage = SavedSlackMessage(), |
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.
don't provide the default.
class SlackMessageInfo( | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
var slackMessage: SavedSlackMessage = SavedSlackMessage(), | ||
var langTag: String = "", |
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.
var langTag: String = "", | |
var languageTag: String = "", |
@@ -146,6 +155,8 @@ class SlackSlashCommandController( | |||
languageTag: String?, | |||
optionsMap: Map<String, String>, | |||
): SlackMessageDto? { | |||
// featureEnabled() |
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 should be removed, right?
@@ -231,6 +242,17 @@ class SlackSlashCommandController( | |||
} | |||
} | |||
|
|||
private fun featureEnabled() { |
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 should be called checkFeatureEnabled
@@ -231,6 +242,17 @@ class SlackSlashCommandController( | |||
} | |||
} | |||
|
|||
private fun featureEnabled() { | |||
try { | |||
enabledFeaturesProvider.checkFeatureEnabled( |
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.
Here you can use isFeatureEnabled
instead of catching generic BRE.
@@ -10,4 +10,6 @@ data class SavedMessageDto( | |||
val langTag: Set<String>, | |||
val createdKeyBlocks: Boolean = false, | |||
val baseChanged: Boolean = false, | |||
// map of langTag and authorContext |
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.
What is author context?
@@ -62,18 +61,20 @@ class SlackExecutor( | |||
} |
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.
Above ^^, You should find the saved messages in one request using in operator in one SQL requests instead of iterating like this. Also the property should be named savedMessages
and then when you iterate over it you got single savedMessage
.