mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-11 02:41:33 +00:00
[AB-96] adding ability to edit/delete modmail messages via editing/deleting the original message causing the message,
adding featuremode to modmail to define whether or not there is a separate message posted to the mod mail thread, to see it easier, renaming modmail related tables to singular, adding some necessary methods (caching) to all entities
This commit is contained in:
@@ -2,11 +2,14 @@ package dev.sheldan.abstracto.core.command.service;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.CommandReceivedHandler;
|
||||
import dev.sheldan.abstracto.core.command.condition.CommandCondition;
|
||||
import dev.sheldan.abstracto.core.command.condition.ConditionResult;
|
||||
import dev.sheldan.abstracto.core.command.condition.ConditionalCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameters;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.UnParsedCommandParameter;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommandInAServer;
|
||||
import dev.sheldan.abstracto.core.command.models.database.AModule;
|
||||
@@ -19,10 +22,12 @@ import dev.sheldan.abstracto.core.models.database.AFeature;
|
||||
import dev.sheldan.abstracto.core.models.database.ARole;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -44,6 +49,12 @@ public class CommandServiceBean implements CommandService {
|
||||
@Autowired
|
||||
private CommandInServerManagementService commandInServerManagementService;
|
||||
|
||||
@Autowired
|
||||
private CommandRegistry commandRegistry;
|
||||
|
||||
@Autowired
|
||||
private CommandReceivedHandler commandReceivedHandler;
|
||||
|
||||
@Override
|
||||
public ACommand createCommand(String name, String moduleName, FeatureEnum featureEnum) {
|
||||
AModule module = moduleManagementService.getOrCreate(moduleName);
|
||||
@@ -151,6 +162,14 @@ public class CommandServiceBean implements CommandService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Parameters> getParametersForCommand(String commandName, Message messageContainingContent) {
|
||||
String contentStripped = messageContainingContent.getContentRaw();
|
||||
UnParsedCommandParameter unParsedParameter = new UnParsedCommandParameter(contentStripped);
|
||||
Command command = commandRegistry.findCommandByParameters(commandName, unParsedParameter);
|
||||
return commandReceivedHandler.getParsedParameters(unParsedParameter, command, messageContainingContent);
|
||||
}
|
||||
|
||||
private ConditionResult checkConditions(CommandContext commandContext, Command command, List<CommandCondition> conditions) {
|
||||
if(conditions != null) {
|
||||
for (CommandCondition condition : conditions) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "lock")
|
||||
@@ -13,7 +14,7 @@ import javax.persistence.*;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class ALock {
|
||||
public class ALock implements Serializable {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@@ -130,10 +130,7 @@ public class BotServiceBean implements BotService {
|
||||
Optional<TextChannel> textChannelOptional = getTextChannelFromServerOptional(serverId, channelId);
|
||||
if(textChannelOptional.isPresent()) {
|
||||
TextChannel textChannel = textChannelOptional.get();
|
||||
return textChannel.deleteMessageById(messageId).submit().exceptionally(throwable -> {
|
||||
log.warn("Deleting the message {} in channel {} in guild {} failed.", messageId, channelId, serverId, throwable);
|
||||
return null;
|
||||
});
|
||||
return textChannel.deleteMessageById(messageId).submit();
|
||||
} else {
|
||||
log.warn("Could not find channel {} in guild {} to delete message {} in.", channelId, serverId, messageId);
|
||||
}
|
||||
|
||||
@@ -275,9 +275,25 @@ public class MessageServiceBean implements MessageService {
|
||||
channelService.sendEmbedTemplateInChannel(template, model, privateChannel).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Message> sendMessageToSendToUser(User user, MessageToSend messageToSend) {
|
||||
return user.openPrivateChannel().submit().thenCompose(privateChannel -> channelService.sendMessageToSendToChannel(messageToSend, privateChannel).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Message> sendMessageToUser(User user, String text) {
|
||||
log.trace("Sending direct string message to user {}.", user.getIdLong());
|
||||
return user.openPrivateChannel().flatMap(privateChannel -> privateChannel.sendMessage(text)).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteMessageInChannelWithUser(User user, Long messageId) {
|
||||
log.info("Deleting message {} in channel with user {}.", messageId, user.getIdLong());
|
||||
return user.openPrivateChannel().flatMap(privateChannel -> privateChannel.deleteMessageById(messageId)).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> editMessageInDMChannel(User user, MessageToSend messageToSend, Long messageId) {
|
||||
return user.openPrivateChannel().submit().thenCompose(privateChannel -> channelService.editMessageInAChannelFuture(messageToSend, privateChannel, messageId).thenApply(message -> null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "command")
|
||||
@@ -16,6 +15,7 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Cacheable
|
||||
@EqualsAndHashCode
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class ACommand implements Serializable {
|
||||
@Id
|
||||
@@ -53,19 +53,4 @@ public class ACommand implements Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ACommand aCommand = (ACommand) o;
|
||||
return Objects.equals(id, aCommand.id) &&
|
||||
Objects.equals(name, aCommand.name) &&
|
||||
Objects.equals(module, aCommand.module) &&
|
||||
Objects.equals(feature, aCommand.feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, module, feature);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity(name = "command_in_server")
|
||||
@Getter
|
||||
@@ -16,6 +15,7 @@ import java.util.Objects;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class ACommandInAServer implements Serializable {
|
||||
@@ -49,23 +49,6 @@ public class ACommandInAServer implements Serializable {
|
||||
@Column
|
||||
private Boolean restricted;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ACommandInAServer that = (ACommandInAServer) o;
|
||||
return Objects.equals(commandInServerId, that.commandInServerId) &&
|
||||
Objects.equals(commandReference, that.commandReference) &&
|
||||
Objects.equals(serverReference, that.serverReference) &&
|
||||
Objects.equals(allowedRoles, that.allowedRoles) &&
|
||||
Objects.equals(immuneRoles, that.immuneRoles) &&
|
||||
Objects.equals(restricted, that.restricted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(commandInServerId, commandReference, serverReference, allowedRoles, immuneRoles, restricted);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package dev.sheldan.abstracto.core.command.models.database;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
@@ -11,7 +8,6 @@ import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "module")
|
||||
@@ -19,6 +15,7 @@ import java.util.Objects;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AModule implements Serializable {
|
||||
@@ -54,18 +51,4 @@ public class AModule implements Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AModule aModule = (AModule) o;
|
||||
return Objects.equals(id, aModule.id) &&
|
||||
Objects.equals(name, aModule.name) &&
|
||||
Objects.equals(commands, aModule.commands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, commands);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,15 @@ package dev.sheldan.abstracto.core.command.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.condition.ConditionResult;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameters;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.models.database.ARole;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface CommandService {
|
||||
ACommand createCommand(String name, String moduleName, FeatureEnum featureEnum);
|
||||
@@ -21,4 +25,5 @@ public interface CommandService {
|
||||
void disAllowCommandForRole(ACommand aCommand, ARole role);
|
||||
void disAllowFeatureForRole(FeatureEnum featureEnum, ARole role);
|
||||
ConditionResult isCommandExecutable(Command command, CommandContext commandContext);
|
||||
CompletableFuture<Parameters> getParametersForCommand(String commandName, Message messageContainingContent);
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="channel")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AChannel implements SnowFlake, Serializable {
|
||||
@@ -55,20 +55,5 @@ public class AChannel implements SnowFlake, Serializable {
|
||||
@Transient
|
||||
private boolean fake;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AChannel channel = (AChannel) o;
|
||||
return Objects.equals(id, channel.id) &&
|
||||
Objects.equals(groups, channel.groups) &&
|
||||
Objects.equals(server, channel.server) &&
|
||||
type == channel.type &&
|
||||
Objects.equals(deleted, channel.deleted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, groups, server, type, deleted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="channelGroup")
|
||||
@@ -15,6 +14,7 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AChannelGroup implements Serializable {
|
||||
@@ -49,19 +49,5 @@ public class AChannelGroup implements Serializable {
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
private List<AChannel> channels;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AChannelGroup that = (AChannelGroup) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(groupName, that.groupName) &&
|
||||
Objects.equals(server, that.server) &&
|
||||
Objects.equals(channels, that.channels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, groupName, server, channels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "channel_group_command")
|
||||
@@ -14,6 +13,7 @@ import java.util.Objects;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AChannelGroupCommand implements Serializable {
|
||||
@@ -35,19 +35,4 @@ public class AChannelGroupCommand implements Serializable {
|
||||
@Setter
|
||||
private Boolean enabled;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AChannelGroupCommand that = (AChannelGroupCommand) o;
|
||||
return Objects.equals(commandInGroupId, that.commandInGroupId) &&
|
||||
Objects.equals(command, that.command) &&
|
||||
Objects.equals(group, that.group) &&
|
||||
Objects.equals(enabled, that.enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(commandInGroupId, command, group, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="systemConfig")
|
||||
@@ -14,6 +13,7 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AConfig implements Serializable {
|
||||
@@ -70,20 +70,5 @@ public class AConfig implements Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AConfig config = (AConfig) o;
|
||||
return Objects.equals(id, config.id) &&
|
||||
Objects.equals(name, config.name) &&
|
||||
Objects.equals(stringValue, config.stringValue) &&
|
||||
Objects.equals(doubleValue, config.doubleValue) &&
|
||||
Objects.equals(server, config.server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, stringValue, doubleValue, server);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.models.database;
|
||||
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
@@ -12,6 +13,9 @@ import java.time.Instant;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class ADefaultConfig implements Serializable {
|
||||
@javax.persistence.Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "emote")
|
||||
@@ -14,6 +13,7 @@ import java.util.Objects;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AEmote implements Serializable {
|
||||
@@ -71,22 +71,4 @@ public class AEmote implements Serializable {
|
||||
@Transient
|
||||
private boolean fake;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AEmote emote = (AEmote) o;
|
||||
return Objects.equals(id, emote.id) &&
|
||||
Objects.equals(name, emote.name) &&
|
||||
Objects.equals(emoteKey, emote.emoteKey) &&
|
||||
Objects.equals(emoteId, emote.emoteId) &&
|
||||
Objects.equals(animated, emote.animated) &&
|
||||
Objects.equals(custom, emote.custom) &&
|
||||
Objects.equals(serverRef, emote.serverRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, emoteKey, emoteId, animated, custom, serverRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="feature")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AFeature implements SnowFlake, Serializable {
|
||||
@@ -52,18 +52,5 @@ public class AFeature implements SnowFlake, Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AFeature feature = (AFeature) o;
|
||||
return Objects.equals(id, feature.id) &&
|
||||
Objects.equals(key, feature.key) &&
|
||||
Objects.equals(commands, feature.commands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, key, commands);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="feature_flag")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AFeatureFlag implements Serializable {
|
||||
@@ -62,19 +62,5 @@ public class AFeatureFlag implements Serializable {
|
||||
this.updateTimestamp = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AFeatureFlag that = (AFeatureFlag) o;
|
||||
return enabled == that.enabled &&
|
||||
Objects.equals(id, that.id) &&
|
||||
Objects.equals(server, that.server) &&
|
||||
Objects.equals(feature, that.feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, server, feature, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.time.Instant;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AFeatureMode implements Serializable {
|
||||
|
||||
@@ -7,13 +7,13 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="role")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class ARole implements SnowFlake, Serializable {
|
||||
@@ -52,21 +52,6 @@ public class ARole implements SnowFlake, Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ARole role = (ARole) o;
|
||||
return Objects.equals(id, role.id) &&
|
||||
Objects.equals(server, role.server) &&
|
||||
Objects.equals(deleted, role.deleted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, server, deleted);
|
||||
}
|
||||
|
||||
public String getAsMention() {
|
||||
return "<@&" + getId() + '>';
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "server")
|
||||
@@ -17,6 +16,7 @@ import java.util.Objects;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AServer implements SnowFlake, Serializable {
|
||||
@@ -89,16 +89,4 @@ public class AServer implements SnowFlake, Serializable {
|
||||
private List<AEmote> emotes = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AServer aServer = (AServer) o;
|
||||
return Objects.equals(id, aServer.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="auser")
|
||||
@@ -15,6 +14,7 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AUser implements Serializable {
|
||||
@@ -45,17 +45,4 @@ public class AUser implements Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AUser user = (AUser) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(servers, user.servers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, servers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user_in_server")
|
||||
@@ -15,6 +14,7 @@ import java.util.Objects;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AUserInAServer implements Serializable {
|
||||
@@ -47,18 +47,4 @@ public class AUserInAServer implements Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AUserInAServer that = (AUserInAServer) o;
|
||||
return Objects.equals(userInServerId, that.userInServerId) &&
|
||||
Objects.equals(userReference, that.userReference) &&
|
||||
Objects.equals(serverReference, that.serverReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(userInServerId, userReference, serverReference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "counter")
|
||||
@@ -13,9 +14,10 @@ import javax.persistence.*;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class Counter {
|
||||
public class Counter implements Serializable {
|
||||
|
||||
@EmbeddedId
|
||||
private CounterId counterId;
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "default_emote")
|
||||
@@ -14,6 +13,7 @@ import java.util.Objects;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class DefaultEmote implements Serializable {
|
||||
@@ -45,20 +45,5 @@ public class DefaultEmote implements Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DefaultEmote that = (DefaultEmote) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(name, that.name) &&
|
||||
Objects.equals(emoteKey, that.emoteKey) &&
|
||||
Objects.equals(created, that.created) &&
|
||||
Objects.equals(updated, that.updated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, emoteKey, created, updated);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="default_feature_flag")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class DefaultFeatureFlag implements Serializable {
|
||||
@@ -53,21 +53,5 @@ public class DefaultFeatureFlag implements Serializable {
|
||||
this.updateTimestamp = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DefaultFeatureFlag that = (DefaultFeatureFlag) o;
|
||||
return enabled == that.enabled &&
|
||||
Objects.equals(id, that.id) &&
|
||||
Objects.equals(feature, that.feature) &&
|
||||
Objects.equals(mode, that.mode) &&
|
||||
Objects.equals(created, that.created) &&
|
||||
Objects.equals(updateTimestamp, that.updateTimestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, feature, enabled, mode, created, updateTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import java.util.List;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Cacheable
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class DefaultFeatureMode implements Serializable {
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="default_posttarget")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class DefaultPostTarget implements Serializable {
|
||||
|
||||
@@ -6,13 +6,13 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="posttarget")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class PostTarget implements Serializable {
|
||||
@@ -51,19 +51,5 @@ public class PostTarget implements Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PostTarget that = (PostTarget) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(name, that.name) &&
|
||||
Objects.equals(channelReference, that.channelReference) &&
|
||||
Objects.equals(serverReference, that.serverReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, channelReference, serverReference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package dev.sheldan.abstracto.core.service;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -39,5 +39,8 @@ public interface MessageService {
|
||||
CompletableFuture<Message> sendTemplateToUser(User user, String template, Object model);
|
||||
CompletableFuture<Void> sendEmbedToUser(User user, String template, Object model);
|
||||
CompletableFuture<Message> sendEmbedToUserWithMessage(User user, String template, Object model);
|
||||
CompletableFuture<Message> sendMessageToSendToUser(User user, MessageToSend messageToSend);
|
||||
CompletableFuture<Message> sendMessageToUser(User user, String text);
|
||||
CompletableFuture<Void> deleteMessageInChannelWithUser(User user, Long messageId);
|
||||
CompletableFuture<Void> editMessageInDMChannel(User user, MessageToSend messageToSend, Long messageId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user