Skip to content

Commit 960841a

Browse files
committed
Extract unpin scheduler interface into a standalone module
1 parent 629f698 commit 960841a

File tree

9 files changed

+62
-61
lines changed

9 files changed

+62
-61
lines changed

pins/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies {
77
api(libs.tgbotapi)
88
api(project.projects.monies)
99
implementation(project.projects.pins.dto)
10+
implementation(project.projects.pins.scheduler)
1011
implementation(libs.log4j.api)
1112

1213
testImplementation(libs.junit.jupiter.api)

pins/dto/src/main/java/by/jprof/telegram/bot/pins/dto/Unpin.java

Lines changed: 49 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,53 @@
33
import java.util.Objects;
44

55
public class Unpin {
6-
private Long messageId;
7-
private Long chatId;
8-
private Long userId;
9-
private Long ttl;
10-
11-
public Long getMessageId() {
12-
return messageId;
13-
}
14-
15-
public void setMessageId(Long messageId) {
16-
this.messageId = messageId;
17-
}
18-
19-
public Long getChatId() {
20-
return chatId;
21-
}
22-
23-
public void setChatId(Long chatId) {
24-
this.chatId = chatId;
25-
}
26-
27-
public Long getUserId() {
28-
return userId;
29-
}
30-
31-
public void setUserId(Long userId) {
32-
this.userId = userId;
33-
}
34-
35-
public Long getTtl() {
36-
return ttl;
37-
}
38-
39-
public void setTtl(Long ttl) {
40-
this.ttl = ttl;
41-
}
42-
43-
@Override
44-
public boolean equals(Object o) {
45-
if (this == o) return true;
46-
if (o == null || getClass() != o.getClass()) return false;
47-
Unpin unpin = (Unpin) o;
48-
return Objects.equals(messageId, unpin.messageId) && Objects.equals(chatId, unpin.chatId) && Objects.equals(userId, unpin.userId) && Objects.equals(ttl, unpin.ttl);
49-
}
50-
51-
@Override
52-
public int hashCode() {
53-
return Objects.hash(messageId, chatId, userId, ttl);
54-
}
55-
56-
@Override
57-
public String toString() {
58-
return "Unpin{" +
59-
"messageId=" + messageId +
60-
", chatId=" + chatId +
61-
", userId=" + userId +
62-
", ttl=" + ttl +
63-
'}';
64-
}
6+
private Long messageId;
7+
private Long chatId;
8+
private Long ttl;
9+
10+
public Long getMessageId() {
11+
return messageId;
12+
}
13+
14+
public void setMessageId(Long messageId) {
15+
this.messageId = messageId;
16+
}
17+
18+
public Long getChatId() {
19+
return chatId;
20+
}
21+
22+
public void setChatId(Long chatId) {
23+
this.chatId = chatId;
24+
}
25+
26+
public Long getTtl() {
27+
return ttl;
28+
}
29+
30+
public void setTtl(Long ttl) {
31+
this.ttl = ttl;
32+
}
33+
34+
@Override
35+
public boolean equals(Object o) {
36+
if (this == o) return true;
37+
if (o == null || getClass() != o.getClass()) return false;
38+
Unpin unpin = (Unpin) o;
39+
return Objects.equals(messageId, unpin.messageId) && Objects.equals(chatId, unpin.chatId) && Objects.equals(ttl, unpin.ttl);
40+
}
41+
42+
@Override
43+
public int hashCode() {
44+
return Objects.hash(messageId, chatId, ttl);
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return "Unpin{" +
50+
"messageId=" + messageId +
51+
", chatId=" + chatId +
52+
", ttl=" + ttl +
53+
'}';
54+
}
6555
}

pins/scheduler/README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
= Pins / Unpin Scheduler
2+
3+
Message unpin scheduler interface.

pins/scheduler/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
kotlin("jvm")
3+
}
4+
5+
dependencies {
6+
api(project.projects.pins.dto)
7+
}

pins/sfn/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
dependencies {
66
api(project.projects.pins)
77
api(project.projects.pins.dto)
8+
api(project.projects.pins.scheduler)
89
api(libs.sfn)
910
implementation(libs.kotlinx.coroutines.jdk8)
1011

pins/sfn/src/main/kotlin/by/jprof/telegram/bot/pins/sfn/scheduler/UnpinScheduler.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class UnpinScheduler(
1616
it.input("""{
1717
| "messageId": ${unpin.messageId},
1818
| "chatId": ${unpin.chatId},
19-
| "userId": ${unpin.userId},
2019
| "ttl": ${unpin.ttl}
2120
|}""".trimMargin())
2221
}.await()

pins/src/main/kotlin/by/jprof/telegram/bot/pins/PinCommandUpdateProcessor.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class PinCommandUpdateProcessor(
8888
unpinScheduler.scheduleUnpin(Unpin().apply {
8989
messageId = pin.message.messageId
9090
chatId = pin.chat.id.chatId
91-
userId = pin.user.id.chatId
9291
ttl = duration.duration.seconds
9392
})
9493
} catch (e: Exception) {

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ include(":quizoji:dynamodb")
2525
include(":eval")
2626
include(":pins")
2727
include(":pins:dto")
28+
include(":pins:scheduler")
2829
include(":pins:unpin")
2930
include(":pins:dynamodb")
3031
include(":pins:sfn")

0 commit comments

Comments
 (0)