Compare commits

...

33 Commits

Author SHA1 Message Date
release-bot
bb6afc82dd Commit from GitHub Actions (Publishes a new version of OnePlusBot) 2025-10-12 20:55:09 +00:00
release-bot
fea16496c4 [maven-release-plugin] prepare for next development iteration 2025-10-12 20:49:47 +00:00
release-bot
c91f27a716 [maven-release-plugin] prepare release oneplusbot-1.7.4 2025-10-12 20:49:46 +00:00
Sheldan
a109d3f36d [OPB-xxx] upgrading abstracto to receive components v2
updating alpine images
2025-10-12 22:45:50 +02:00
release-bot
135c693bc8 Commit from GitHub Actions (Publishes a new version of OnePlusBot) 2025-08-16 11:23:20 +00:00
release-bot
ff284d4e10 [maven-release-plugin] prepare for next development iteration 2025-08-16 11:18:40 +00:00
release-bot
d4eb9ffad5 [maven-release-plugin] prepare release oneplusbot-1.7.3 2025-08-16 11:18:39 +00:00
Sheldan
976defa902 [OPB-xxx] adding docker and helm build to build job 2025-08-16 13:10:10 +02:00
Sheldan
96d5ca06e7 [OPB-xxx] adding feature mode to fully automate news posts 2025-08-16 13:08:22 +02:00
release-bot
bdcfccf5ad Commit from GitHub Actions (Publishes a new version of OnePlusBot) 2025-06-15 06:25:16 +00:00
release-bot
e60ab82870 [maven-release-plugin] prepare for next development iteration 2025-06-15 06:20:23 +00:00
release-bot
2ca92279ae [maven-release-plugin] prepare release oneplusbot-1.7.2 2025-06-15 06:20:22 +00:00
Sheldan
fc41501a21 [OPB-xxx] a limit for user posts was added 2025-06-15 08:17:12 +02:00
release-bot
320efc91b4 [maven-release-plugin] prepare for next development iteration 2025-05-29 20:25:10 +00:00
release-bot
3bcfca46b6 [maven-release-plugin] prepare release oneplusbot-1.7.1 2025-05-29 20:25:09 +00:00
Sheldan
615d1d10b5 [OPB-xxx] updating abstracto version to 1.6.8 for fixes
preparing for release
2025-05-29 22:20:46 +02:00
Sheldan
2926d9fe09 [OPB-xxx] updating policy 2025-02-23 23:08:46 +01:00
Sheldan
edad07ac94 [OPB-xxx] updating privacy policy 2025-02-23 22:56:22 +01:00
release-bot
d1eeb15253 Commit from GitHub Actions (Publishes a new version of OnePlusBot) 2025-02-23 21:01:35 +00:00
release-bot
6b0bbca290 [maven-release-plugin] prepare for next development iteration 2025-02-23 20:57:37 +00:00
release-bot
780c0d05bc [maven-release-plugin] prepare release oneplusbot-1.7.0 2025-02-23 20:57:36 +00:00
Sheldan
14d4091bf7 [OPB-xxx] updating abstracto version to 1.6.4 to get better command permissions, user installable application support, reducing docker image size, 2025-02-23 21:54:30 +01:00
release-bot
c4e1ce6cd7 Commit from GitHub Actions (Publishes a new version of OnePlusBot) 2025-01-27 21:10:30 +00:00
release-bot
06fd28e536 [maven-release-plugin] prepare for next development iteration 2025-01-27 21:05:48 +00:00
release-bot
00db737bdb [maven-release-plugin] prepare release oneplusbot-1.6.36 2025-01-27 21:05:46 +00:00
Sheldan
161327f27e [OPB-xxx] updating abstracto version to 1.5.57 to get better emote tracking 2025-01-27 22:02:13 +01:00
release-bot
d15f025309 Commit from GitHub Actions (Publishes a new version of OnePlusBot) 2025-01-15 22:14:03 +00:00
release-bot
b7555e9851 [maven-release-plugin] prepare for next development iteration 2025-01-15 22:09:50 +00:00
release-bot
3aef21f281 [maven-release-plugin] prepare release oneplusbot-1.6.35 2025-01-15 22:09:48 +00:00
Sheldan
597d3b8a8a [OPB-xxx] updating abstracto version to 1.5.57
adding config for currency conversion
fixing ban message template folder name
2025-01-15 23:06:44 +01:00
release-bot
bc353fed55 Commit from GitHub Actions (Publishes a new version of OnePlusBot) 2024-11-22 22:22:14 +00:00
release-bot
31279bb059 [maven-release-plugin] prepare for next development iteration 2024-11-22 22:16:29 +00:00
release-bot
8e6804a1dc [maven-release-plugin] prepare release oneplusbot-1.6.34 2024-11-22 22:16:28 +00:00
64 changed files with 323 additions and 112 deletions

4
.env
View File

@@ -1,4 +1,4 @@
REGISTRY_PREFIX=harbor.sheldan.dev/oneplus-bot/
ABSTRACTO_PREFIX=harbor.sheldan.dev/abstracto/
VERSION=1.6.33
ABSTRACTO_VERSION=1.5.51
VERSION=1.7.4
ABSTRACTO_VERSION=1.6.15

View File

@@ -31,3 +31,23 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
user: Sheldan
token: ${{ secrets.ABSTRACTO_PAT }}
- name: Login to Harbor
uses: docker/login-action@v3
with:
registry: harbor.sheldan.dev
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: Load env file
id: dotenv
uses: falti/dotenv-action@v1.0.4
with:
path: .env
- name: Docker build
run: docker compose build
env:
REGISTRY_PREFIX: ${{ steps.dotenv.outputs.registry_prefix }}
VERSION: ${{ steps.dotenv.outputs.version }}
- name: Helm package and push
working-directory: ./deployment/helm/
run: |-
helm package oneplus-bot

View File

@@ -1,6 +1,6 @@
# r/oneplus Discord bot privacy policy
Last updated: 06.09.2021
Last updated: 23.02.2025
## Description
@@ -16,17 +16,20 @@ The detailed list of what information is stored and processed is the following:
* the name of emotes which are used in the bot for convenience, if they are customized
* towards which channel (identified by ID) certain messages by the bot are posted. e.g. logging, news, starboard
* **no message content, username, channel name or role name is stored, except at the places where its mentioned**
* a logfile is used in order to examine any malfunctions, the content is deleted after 7 days
* most of the stored records have a 'created' and 'updated' timestamp, in order to assist in examining bugs and malfunctions
* which commands have which cooldown in which channel group and in which channel group they are disabled
* which channel is in which channel group
* which role is allowed to execute which command
* which features are enabled
* which feature modes are enabled
* **aliases** created for the commands
* **information** necessary to handle components (buttons, select menus). This information is of varying nature and can be user identifiable information
* **emotes** which should be used for varying places (assignable roles, particular emotes which are overwriten, such as star board)
### Moderation
* the date of the latest report via the reaction report system, in order to disallow quick reports
* mute reason, duration, mute date, who muted whom and in which message was the mute executed
* **mute reason**, duration, mute date, who muted whom and in which message was the mute executed
* the names of filtered invite link servers in order to find out if it would be valid to allow the invite
* any configured allowed invite links the server ID and the actually used invite
* this is necessary in order to determine the server via its ID and allow other unknown invite links. The invite link is necessary as there is no way to map server ID to actual server
@@ -41,6 +44,9 @@ The detailed list of what information is stored and processed is the following:
* the user who warned a user
* whether the warning was decayed and when
### Giveaway
* the give away information: **description**, provider, manager, target date, winners and participants
### Embedded messages
* embedded message information
* this information includes who embedded which message in which channel and is deleted after a few days
@@ -49,10 +55,12 @@ The detailed list of what information is stored and processed is the following:
* the name of emotes which are being tracked in the emote usage tracking system for purely convenience reasons
* **who** used which emote is **not** tracked
* at which day an emote was used how many times
* whether the emote was a reaction
### News
* general information about news posts
* the source message of the command, the created news post, and the author in order to enable the update mechanism
* news posts from the oneplus Forums for automatic retrieval and comparison to see which posts are new. The ID of the users for who the forum posts are checked.
### Referral system
* the date of the latest referral post in order to enforce the referral bump mechanism
@@ -62,6 +70,13 @@ The detailed list of what information is stored and processed is the following:
* the date it was created, and the date it is due
* the id of the message which contained the command
* whether you have been reminded
* the users who have joined the reminders
### Modmail
* the information that a modmail thread existed (creation, status and close date), and the IDs of the messages that have been sent in both directions
### Polls
* the **text** of polls, the creator of polls and who made which decision in polls
### Starboard
* the message which was the origin for the starboard post
@@ -71,11 +86,11 @@ The detailed list of what information is stored and processed is the following:
* this is necessary to provide the information about 'top star giver' and to disallow duplicate starboard reactions
### Suggestion
* *the message content* of the message used to create the suggestion
* **the message content** of the message used to create the suggestion
* this was used for the message used to update the status of a suggestion, but this is currently disabled
* the author of the suggestion and the message which has been posted in the suggestions channel
* every suggestion will be deleted completely from the database a few days after it has reached a final state (rejected, denied, accepted)
* whether you voted for a suggestion and which decision you took
* whether you voted for a suggestion and which decision you made
### Leveling system
* the amount of messages which were considered for the leveling system
@@ -86,6 +101,10 @@ The detailed list of what information is stored and processed is the following:
* which roles are configured to be used as experience roles and at which level they are assigned
* which roles are used to disable experience gain
### Entertainment
* PressF: for **what** the pressF was initiated by whom and who participated
### FAQ
* the names of FAQ commands
* in which channel groups a FAQ command has a response
@@ -100,6 +119,7 @@ The detailed list of what information is stored and processed is the following:
### Assignable roles
* the names of assignable role places and assignable role button text, together with the associated emote markdown (if given)
* the assigned assignable roles for each member in order to provide the 'unique' assignable role functionality
* custom configured conditions to enable a level restriction
## Grafana dashboard
@@ -121,7 +141,7 @@ All of this information cannot be linked to any user (or any server for that mat
## How can I decide which information is collected?
It is not possible to opt-out of singular sub-services of the bot. Should you decide that your information should not be collected, please cease usage of the bot immediately (leave any guild the bot operates in).
_Should you decide to no longer utilize the bot, you may request your data to be erased within 30 days as per GDPR if you are a citizen of the EU. You can do this by sending an email to oneplus.appeals@pm.me with the subject: GDPR Data removal <Username#0000> <UserId>. If your request is incomplete, we cannot acknowledge it and therefore your data will not be removed. In order to identify authentic requests, please contact modmail beforehand by sending a direct message to the bot and stating your intention._
_Should you decide to no longer utilize the bot, you may request your data to be erased within 30 days as per GDPR if you are a citizen of the EU. You can do this by sending a message to the user "sheldan" on Discord: GDPR Data removal <Username> <UserId>. If your request is incomplete, we cannot acknowledge it and therefore your data will not be removed. In order to identify authentic requests, please contact modmail beforehand by sending a direct message to the bot and stating your intention._
## Legal information
@@ -134,7 +154,7 @@ OnePlus and OPPO are legal owners of OxygenOS. Visit https://oneplus.com/brand t
## Open source content
This bot uses the following open source libraries and frameworks:
* [abstracto](https://github.com/Sheldan/abstracto) is used as a base for this bot, providing a lot of the functionalities
* [abstracto](https://github.com/Sheldan/abstracto) is used as a base for this bot, providing most of the functionalities
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper used
* [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including Dependency injection and more)
* [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA.
@@ -142,7 +162,8 @@ This bot uses the following open source libraries and frameworks:
* [Ehcache](https://github.com/ehcache/ehcache3) is used as a caching implementation.
* [Lombok](https://github.com/rzwitserloot/lombok) is used as a framework in order to speed up creation of container classes and builders.
* [Quartz](https://github.com/quartz-scheduler/quartz) is used as a scheduling framework in order to provide functionalities which either require a delayed or cronjob behaviour.
* [Docker](https://github.com/docker) is used to package the application into a container and [Docker Compose](https://github.com/docker/compose) is used to orchestrate the containers
* [Docker](https://github.com/docker) is used to package the application into a container and [k3s](https://k3s.io/) to orchestrate the containers
* [Liquibase](https://github.com/liquibase/liquibase) is used to manage changes to the database
* [Prometheus](https://prometheus.io) to scrap and collect the metrics about how the bot is operating
* [Grafana](https://grafana.com) to visualize metrics of the bot
* [Grafana](https://grafana.com) to visualize metrics of the bot and [Loki](https://grafana.com/oss/loki/) for logging

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application</groupId>
<artifactId>application</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>executable</artifactId>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
<artifactId>oneplus-bot-customizations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>oneplus-bot-customizations</artifactId>
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application</groupId>
<artifactId>application</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
<artifactId>oneplus-bot-customizations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>oneplus-bot-modules</artifactId>
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -8,10 +8,7 @@ import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.service.JSONValidationService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import dev.sheldan.abstracto.core.utils.FileService;
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureDefinition;
import dev.sheldan.oneplus.bot.modules.faq.config.FAQModuleDefinition;
import dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean;
@@ -27,18 +24,9 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
public class DeleteFAQ extends AbstractConditionableCommand {
@Autowired
private FileService fileService;
@Autowired
private FAQServiceBean faqServiceBean;
@Autowired
private ChannelService channelService;
@Autowired
private JSONValidationService jsonValidationService;
@Autowired
private ServerManagementService serverManagementService;

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
<artifactId>oneplus-bot-modules</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -36,10 +36,24 @@ public class UpdateNews extends AbstractConditionableCommand {
@Override
public CommandConfiguration getConfiguration() {
Parameter newsPostId = Parameter.builder().name("newsPostId").type(Long.class).templated(true).build();
Parameter newsText = Parameter.builder().name("text").type(String.class).remainder(true).templated(true).build();
Parameter newsPostId = Parameter
.builder()
.name("newsPostId")
.type(Long.class)
.templated(true)
.build();
Parameter newsText = Parameter
.builder()
.name("text")
.type(String.class)
.remainder(true)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(newsPostId, newsText);
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("updateNews")
.module(NewsModuleDefinition.NEWS)

View File

@@ -2,6 +2,7 @@ package dev.sheldan.oneplus.bot.modules.news.config;
import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.config.FeatureMode;
import dev.sheldan.abstracto.core.config.PostTargetEnum;
import org.springframework.stereotype.Component;
@@ -22,4 +23,9 @@ public class NewsFeature implements FeatureConfig {
public List<PostTargetEnum> getRequiredPostTargets() {
return Arrays.asList(NewsPostTarget.NEWS_TARGET, NewsPostTarget.FORUM_POST_NOTIFICATION);
}
@Override
public List<FeatureMode> getAvailableModes() {
return Arrays.asList(NewsFeatureMode.AUTOMATIC_POST, NewsFeatureMode.AUTOMATIC_PUBLISH);
}
}

View File

@@ -0,0 +1,16 @@
package dev.sheldan.oneplus.bot.modules.news.config;
import dev.sheldan.abstracto.core.config.FeatureMode;
import lombok.Getter;
@Getter
public enum NewsFeatureMode implements FeatureMode {
AUTOMATIC_POST("automaticPost"),
AUTOMATIC_PUBLISH("automaticPublish");
private final String key;
NewsFeatureMode(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,24 @@
package dev.sheldan.oneplus.bot.modules.news.model;
import dev.sheldan.oneplus.bot.modules.news.model.forum.ForumPost;
import lombok.Builder;
import lombok.Getter;
@Builder
@Getter
public class ForumPostEntry {
private Long postId;
private String subject;
private String content;
private Long creatorId;
public static ForumPostEntry fromPost(ForumPost forumPost) {
return ForumPostEntry
.builder()
.postId(forumPost.getId())
.subject(forumPost.getSubject())
.content(forumPost.getContent())
.creatorId(forumPost.getSource().getUserId())
.build();
}
}

View File

@@ -0,0 +1,12 @@
package dev.sheldan.oneplus.bot.modules.news.model;
import lombok.Builder;
import lombok.Getter;
import java.util.List;
@Getter
@Builder
public class ForumPostModel {
private List<ForumPostEntry> entries;
}

View File

@@ -1,10 +1,15 @@
package dev.sheldan.oneplus.bot.modules.news.service;
import dev.sheldan.abstracto.core.service.FeatureModeService;
import dev.sheldan.abstracto.core.service.PostTargetService;
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import dev.sheldan.oneplus.bot.modules.news.config.NewsFeatureDefinition;
import dev.sheldan.oneplus.bot.modules.news.config.NewsFeatureMode;
import dev.sheldan.oneplus.bot.modules.news.config.NewsPostTarget;
import dev.sheldan.oneplus.bot.modules.news.model.ForumPostEntry;
import dev.sheldan.oneplus.bot.modules.news.model.ForumPostModel;
import dev.sheldan.oneplus.bot.modules.news.model.ForumPostNotificationEntry;
import dev.sheldan.oneplus.bot.modules.news.model.ForumPostNotificationModel;
import dev.sheldan.oneplus.bot.modules.news.model.database.NewsForumPost;
@@ -13,11 +18,14 @@ import dev.sheldan.oneplus.bot.modules.news.model.forum.ForumPost;
import dev.sheldan.oneplus.bot.modules.news.service.management.NewsForumPostManagementServiceBean;
import dev.sheldan.oneplus.bot.modules.news.service.management.NewsSourceManagementServiceBean;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Message;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -45,7 +53,11 @@ public class NewsSourceServiceBean {
@Autowired
private NewsSourceServiceBean self;
@Autowired
private FeatureModeService featureModeService;
private static final String NEWS_FORUM_POST_NOTIFICATION_TEMPLATE_KEY = "newsForumPost_notification";
private static final String NEWS_FORUM_POST_TEMPLATE_KEY = "newsForumPost";
public void checkForNewThreads() {
Long targetServerId = Long.parseLong(System.getenv(NEWS_FORUM_POST_NOTIFICATION_SERVER_ID_ENV_NAME));
@@ -54,34 +66,75 @@ public class NewsSourceServiceBean {
if(newForumPosts.isEmpty()) {
return;
}
List<ForumPostNotificationEntry> entries = new ArrayList<>();
newForumPosts.forEach(forumPost -> entries.add(ForumPostNotificationEntry.fromPost(forumPost)));
ForumPostNotificationModel model = ForumPostNotificationModel
.builder()
.entries(entries)
.build();
if(featureModeService.featureModeActive(NewsFeatureDefinition.NEWS, targetServerId, NewsFeatureMode.AUTOMATIC_POST)) {
List<ForumPostEntry> entries = new ArrayList<>();
newForumPosts.forEach(forumPost -> entries.add(ForumPostEntry.fromPost(forumPost)));
ForumPostModel model = ForumPostModel
.builder()
.entries(entries)
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate(NEWS_FORUM_POST_TEMPLATE_KEY, model, targetServerId);
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, NewsPostTarget.NEWS_TARGET, targetServerId);
FutureUtils.toSingleFutureGeneric(messageFutures)
.thenAccept(unused -> {
log.info("Sent news forum post notification.");
List<Pair<Long, Long>> posts = entries
.stream()
.map(forumPostNotificationEntry -> Pair.of(forumPostNotificationEntry.getCreatorId(), forumPostNotificationEntry.getPostId()))
.toList();
self.persistForumPostsAndThreadCount(posts);
self.handleAutomaticPublish(messageFutures, targetServerId);
});
} else {
List<ForumPostNotificationEntry> entries = new ArrayList<>();
newForumPosts.forEach(forumPost -> entries.add(ForumPostNotificationEntry.fromPost(forumPost)));
ForumPostNotificationModel model = ForumPostNotificationModel
.builder()
.entries(entries)
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate(NEWS_FORUM_POST_NOTIFICATION_TEMPLATE_KEY, model, targetServerId);
FutureUtils.toSingleFutureGeneric(postTargetService.sendEmbedInPostTarget(messageToSend, NewsPostTarget.FORUM_POST_NOTIFICATION, targetServerId))
.thenAccept(unused -> {
log.info("Sent news forum post notification.");
List<Pair<Long, Long>> posts = entries
.stream()
.map(forumPostNotificationEntry -> Pair.of(forumPostNotificationEntry.getCreatorId(), forumPostNotificationEntry.getPostId()))
.toList();
self.persistForumPostsAndThreadCount(posts);
}).exceptionally(throwable -> {
log.error("Failed to send news forum post notification.", throwable);
return null;
});
}
MessageToSend messageToSend = templateService.renderEmbedTemplate(NEWS_FORUM_POST_NOTIFICATION_TEMPLATE_KEY, model, targetServerId);
FutureUtils.toSingleFutureGeneric(postTargetService.sendEmbedInPostTarget(messageToSend, NewsPostTarget.FORUM_POST_NOTIFICATION, targetServerId))
.thenAccept(unused -> {
log.info("Sent news forum post notification.");
self.persistForumPostsAndThreadCount(entries);
}).exceptionally(throwable -> {
log.error("Failed to send news forum post notification.", throwable);
return null;
});
}
@Transactional
public void persistForumPostsAndThreadCount(List<ForumPostNotificationEntry> entries) {
public CompletableFuture<Message> handleAutomaticPublish(List<CompletableFuture<Message>> messageFutures, Long serverId) {
if(featureModeService.featureModeActive(NewsFeatureDefinition.NEWS, serverId, NewsFeatureMode.AUTOMATIC_PUBLISH)) {
if(messageFutures != null && !messageFutures.isEmpty() && messageFutures.get(0) != null) {
Message newsMessage = messageFutures.get(0).join();
log.info("Publishing message {} in server {}.", newsMessage.getId(), serverId);
return newsMessage.crosspost().submit();
} else {
log.info("No message found - not cross posting.");
return CompletableFuture.completedFuture(null);
}
} else {
log.info("Automatic publishing disabled in server {}.", serverId);
return CompletableFuture.completedFuture(null);
}
}
@Transactional
public void persistForumPostsAndThreadCount(List<Pair<Long, Long>> posts) {
Map<Long, NewsSource> sourceMap = newsSourceManagementServiceBean.loadNewsSources()
.stream()
.collect(Collectors.toMap(NewsSource::getUserId, Function.identity()));
entries.forEach(forumPostNotificationEntry ->
newsForumPostManagementServiceBean.createPost(sourceMap.get(forumPostNotificationEntry.getCreatorId()), forumPostNotificationEntry.getPostId()));
posts.forEach(forumPostNotificationEntry ->
newsForumPostManagementServiceBean.createPost(sourceMap.get(forumPostNotificationEntry.getLeft()), forumPostNotificationEntry.getRight()));
sourceMap.values().forEach(newsSource -> {
Long currentThreadCount = forumApiClient.getCurrentThreadCount(newsSource);

View File

@@ -7,6 +7,14 @@ abstracto.featureFlags.news.enabled=false
abstracto.feature.news.removalDays=4
abstracto.feature.news.postLockSeconds=3600
abstracto.featureModes.automaticPublish.featureName=news
abstracto.featureModes.automaticPublish.mode=automaticPublish
abstracto.featureModes.automaticPublish.enabled=false
abstracto.featureModes.automaticPost.featureName=news
abstracto.featureModes.automaticPost.mode=automaticPost
abstracto.featureModes.automaticPost.enabled=false
abstracto.feature.news.userURL=https://community.oneplus.com/ajax/user/frontend/user/info?uid=%s
# TODO support pagination.. eventually
abstracto.feature.news.threadURL=https://community.oneplus.com/ajax/user/frontend/thread/page?page=1&limit=1000&uid=%s
abstracto.feature.news.threadURL=https://community.oneplus.com/ajax/user/frontend/thread/page?page=1&limit=100&uid=%s

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application</groupId>
<artifactId>application</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
<artifactId>oneplus-bot-modules</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
<artifactId>oneplus-bot-modules</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>oneplus-bot-modules</artifactId>
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,13 +5,13 @@
<parent>
<groupId>dev.sheldan.oneplus.bot</groupId>
<artifactId>oneplusbot</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<groupId>dev.sheldan.oneplus.bot.application</groupId>
<artifactId>application</artifactId>
<packaging>pom</packaging>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
<modules>
<module>executable</module>
<module>oneplus-bot-customizations</module>

View File

@@ -2,4 +2,4 @@ apiVersion: v2
name: oneplus-bot
description: A Helm chart for Kubernetes
type: application
version: 1.6.33
version: 1.7.4

View File

@@ -4,4 +4,5 @@ metadata:
name: api-keys
data:
discordToken: {{ $.Values.apiKeys.discord.token | b64enc }} # b64enc is needed, because a stringData secret field cannot hold numeric values
youtubeApiKey: {{ $.Values.apiKeys.youtube.apiKey | b64enc }}
youtubeApiKey: {{ $.Values.apiKeys.youtube.apiKey | b64enc }}
freeCurrencyApiApiKey: {{ $.Values.apiKeys.freeCurrencyApi.apiKey | b64enc }}

View File

@@ -75,6 +75,11 @@ spec:
key: youtubeApiKey
- name: PRIVATE_REST_API_HOST
value: "{{ .Values.privateRestApi.service.name }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: FREE_CURRENCY_API_API_KEY
valueFrom:
secretKeyRef:
name: api-keys
key: freeCurrencyApiApiKey
- name: PRIVATE_REST_API_PORT
value: "{{ .Values.privateRestApi.service.targetPort }}"
- name: FRONTEND_BASE

View File

@@ -3,7 +3,7 @@ bot:
repository: harbor.sheldan.dev/oneplus-bot
pullPolicy: IfNotPresent
image: oneplus-bot-image
tag: 1.6.33
tag: 1.7.4
livenessProbe:
initialDelaySeconds: 60
periodSeconds: 5
@@ -22,23 +22,23 @@ templateDeployment:
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-template-deployment
tag: 1.5.51
tag: 1.6.15
templateDeploymentData:
repository: harbor.sheldan.dev/oneplus-bot
pullPolicy: Always
image: oneplus-bot-template-data
tag: 1.6.33
tag: 1.7.4
dbConfigDeployment:
enabled: true
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-db-deployment
tag: 1.5.51
tag: 1.6.15
dbConfigDeploymentData:
repository: harbor.sheldan.dev/oneplus-bot
pullPolicy: Always
image: oneplus-bot-db-data
tag: 1.6.33
tag: 1.7.4
dbCredentials:
host: null
port: null
@@ -51,7 +51,7 @@ privateRestApi:
repository: harbor.sheldan.dev/oneplus-bot
pullPolicy: Always
image: oneplus-bot-private-rest-api
tag: 1.6.33
tag: 1.7.4
podAnnotations: {}
podSecurityContext: {}
securityContext: {}
@@ -82,7 +82,7 @@ restApi:
repository: harbor.sheldan.dev/oneplus-bot
pullPolicy: Always
image: oneplus-bot-rest-api
tag: 1.6.33
tag: 1.7.4
podAnnotations: {}
podSecurityContext: {}
securityContext: {}
@@ -138,6 +138,8 @@ apiKeys:
twitch:
secret: null
clientId: null
freeCurrencyApi:
apiKey: null
imagePullSecrets: null
nameOverride: ''
fullnameOverride: ''

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.deployment</groupId>
<artifactId>deployment</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -1,4 +1,4 @@
FROM alpine:3.18.0
FROM alpine:3.22.1
MAINTAINER Sheldan
ADD config/ /var/db-config/
ADD liquibase-artifacts /var/db-config/liquibase-zips

View File

@@ -1,8 +1,32 @@
FROM amazoncorretto:17.0.8-alpine3.18
MAINTAINER Sheldan
VOLUME /tmp
ADD config/* /config/
ADD wrapper/*.sh /
# https://careers.wolt.com/en/blog/tech/how-to-reduce-jvm-docker-image-size
FROM amazoncorretto:17.0.14-alpine3.20 AS corretto-jdk
RUN apk add --no-cache binutils
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /customjre
FROM alpine:3.22.1
ENV JAVA_HOME=/jre
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=corretto-jdk /customjre $JAVA_HOME
ARG APPLICATION_USER=appuser
RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER
RUN mkdir /app && chown -R $APPLICATION_USER /app
COPY --chown=1000:1000 config/* /config/
COPY --chown=1000:1000 wrapper/*.sh /
RUN chmod +x /start.sh
ADD bot/app.jar /app.jar
COPY --chown=1000:1000 bot/app.jar /app.jar
CMD ["/start.sh"]

View File

@@ -1,4 +1,4 @@
FROM alpine:3.18.0
FROM alpine:3.22.1
MAINTAINER Sheldan
ADD config /var/template-config/
ADD template-artifacts /var/template-config/templates

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>oneplusbot</artifactId>
<groupId>dev.sheldan.oneplus.bot</groupId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -12,13 +12,13 @@
<groupId>dev.sheldan.oneplus.bot</groupId>
<artifactId>oneplusbot</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<abstracto.version>1.5.51</abstracto.version>
<abstracto.templates.version>1.4.46</abstracto.templates.version>
<abstracto.version>1.6.15</abstracto.version>
<abstracto.templates.version>1.4.61</abstracto.templates.version>
</properties>
<modules>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.customizations</groupId>
<artifactId>customization-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates</groupId>
<artifactId>oneplus-bot-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.customizations</groupId>
<artifactId>customization-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.modules</groupId>
<artifactId>oneplus-bot-module-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.modules</groupId>
<artifactId>oneplus-bot-module-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -0,0 +1,17 @@
{
<#assign roleMention="<@&479202891358535681>"/>
"additionalMessage": "${roleMention}",
"embeds": [
{
<#macro postDisplay post>
${post.subject?json_string}
https://community.oneplus.com/thread/${post.postId?c}
</#macro>
"description": "<#list entries as entry><@postDisplay post=entry /></#list>"
}
],
"messageConfig": {
"allowsRoleMention": true
}
}

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates</groupId>
<artifactId>oneplus-bot-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.modules</groupId>
<artifactId>oneplus-bot-module-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,13 +3,13 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates</groupId>
<artifactId>templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>oneplus-bot-templates</artifactId>
<packaging>pom</packaging>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
<modules>
<module>module-templates</module>
<module>customization-templates</module>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.overrides</groupId>
<artifactId>template-overrides</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.overrides</groupId>
<artifactId>template-overrides</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.overrides</groupId>
<artifactId>template-overrides</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.overrides</groupId>
<artifactId>template-overrides</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates</groupId>
<artifactId>oneplus-bot-templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.overrides</groupId>
<artifactId>template-overrides</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.overrides</groupId>
<artifactId>template-overrides</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot</groupId>
<artifactId>oneplusbot</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modules>
@@ -14,7 +14,7 @@
<groupId>dev.sheldan.oneplus.bot.templates</groupId>
<artifactId>templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
<packaging>pom</packaging>
</project>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.customizations</groupId>
<artifactId>customization-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.customizations</groupId>
<artifactId>customization-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations</groupId>
<artifactId>translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.customizations</groupId>
<artifactId>customization-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.modules</groupId>
<artifactId>module-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.modules</groupId>
<artifactId>module-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations</groupId>
<artifactId>translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.modules</groupId>
<artifactId>module-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.modules</groupId>
<artifactId>module-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.modules</groupId>
<artifactId>module-translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates</groupId>
<artifactId>templates</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations.overrides</groupId>
<artifactId>translation-overrides</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.oneplus.bot.templates.translations</groupId>
<artifactId>translations</artifactId>
<version>1.6.34-SNAPSHOT</version>
<version>1.7.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>