Skip to content

Commit 8fb4d33

Browse files
committed
fix: lint, try to troubleshoot test failures
1 parent 59475a7 commit 8fb4d33

File tree

5 files changed

+63
-21
lines changed

5 files changed

+63
-21
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.tolgee.configuration
18+
19+
import io.hypersistence.utils.hibernate.query.QueryStackTraceLogger
20+
import org.hibernate.cfg.AvailableSettings
21+
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer
22+
import org.springframework.context.annotation.Profile
23+
import org.springframework.stereotype.Component
24+
25+
@Component
26+
@Profile("hibernate-trace")
27+
class HibernateConfig : HibernatePropertiesCustomizer {
28+
override fun customize(hibernateProperties: MutableMap<String, Any>) {
29+
hibernateProperties[AvailableSettings.STATEMENT_INSPECTOR] = QueryStackTraceLogger("io.tolgee")
30+
}
31+
}

backend/data/src/main/kotlin/io/tolgee/email/EmailService.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,20 @@ class EmailService(
3434
@Qualifier("emailTemplateEngine") private val templateEngine: TemplateEngine,
3535
) {
3636
private val smtpFrom
37-
get() = smtpProperties.from
38-
?: throw IllegalStateException("SMTP sender is not configured. See https://docs.tolgee.io/platform/self_hosting/configuration#smtp")
37+
get() =
38+
smtpProperties.from
39+
?: throw IllegalStateException(
40+
"SMTP sender is not configured. " +
41+
"See https://docs.tolgee.io/platform/self_hosting/configuration#smtp",
42+
)
3943

4044
@Async
4145
fun sendEmailTemplate(
4246
recipient: String,
4347
template: String,
4448
locale: Locale,
4549
properties: Map<String, Any> = mapOf(),
46-
attachments: List<EmailAttachment> = listOf()
50+
attachments: List<EmailAttachment> = listOf(),
4751
) {
4852
val context = Context(locale, properties)
4953
val html = templateEngine.process(template, context)
@@ -57,10 +61,10 @@ class EmailService(
5761
recipient: String,
5862
subject: String,
5963
contents: String,
60-
attachments: List<EmailAttachment> = listOf()
64+
attachments: List<EmailAttachment> = listOf(),
6165
) {
6266
val message = mailSender.createMimeMessage()
63-
val helper = MimeMessageHelper(message, MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED,"UTF8")
67+
val helper = MimeMessageHelper(message, MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED, "UTF8")
6468

6569
helper.setFrom(smtpFrom)
6670
helper.setTo(recipient)

backend/data/src/main/kotlin/io/tolgee/email/EmailTemplateConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class EmailTemplateConfig {
5252
@Bean("emailTemplateEngine")
5353
fun templateEngine(
5454
@Qualifier("emailTemplateResolver") templateResolver: ITemplateResolver,
55-
@Qualifier("emailMessageSource") messageSource: MessageSource
55+
@Qualifier("emailMessageSource") messageSource: MessageSource,
5656
): TemplateEngine {
5757
val templateEngine = SpringTemplateEngine()
5858
templateEngine.templateResolvers = setOf(templateResolver)

backend/data/src/test/kotlin/io/tolgee/email/EmailServiceTest.kt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,26 @@ class EmailServiceTest {
100100
}
101101

102102
companion object {
103-
private val TEST_PROPERTIES = mapOf(
104-
"testVar" to "test!!",
105-
"testList" to listOf(
106-
mapOf("name" to "Name #1"),
107-
mapOf("name" to "Name #2"),
108-
mapOf("name" to "Name #3"),
103+
private val TEST_PROPERTIES =
104+
mapOf(
105+
"testVar" to "test!!",
106+
"testList" to
107+
listOf(
108+
mapOf("name" to "Name #1"),
109+
mapOf("name" to "Name #2"),
110+
mapOf("name" to "Name #3"),
111+
),
109112
)
110-
)
111113

112-
private val TEST_PROPERTIES_MEOW = mapOf(
113-
"testVar" to "meow",
114-
"testList" to listOf(
115-
mapOf("name" to "Name #1"),
116-
mapOf("name" to "Name #2"),
117-
mapOf("name" to "Name #3"),
114+
private val TEST_PROPERTIES_MEOW =
115+
mapOf(
116+
"testVar" to "meow",
117+
"testList" to
118+
listOf(
119+
mapOf("name" to "Name #1"),
120+
mapOf("name" to "Name #2"),
121+
mapOf("name" to "Name #3"),
122+
),
118123
)
119-
)
120124
}
121125
}

gradle/email.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ tasks.register('buildEmails', Exec) {
4646
workingDir = emailPath
4747
commandLine npmCommandName, "run", "export"
4848

49-
inputs.dir("${emailPath}/")
49+
inputs.dir("${emailPath}/emails")
50+
inputs.dir("${emailPath}/components")
51+
inputs.file("${emailPath}/package.json")
52+
inputs.file("${emailPath}/package-lock.json")
5053
outputs.dir("${emailPath}/out/")
5154
}
5255

0 commit comments

Comments
 (0)