[AB-233] adding feature to handle removed attachments in message edited events

now cloning the cached message for the listeners, in order to not influence the objects when updating it
This commit is contained in:
Sheldan
2021-04-24 18:03:06 +02:00
parent 27763e985d
commit 53bef3fdb3
18 changed files with 105 additions and 27 deletions

View File

@@ -6,11 +6,13 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
@EqualsAndHashCode
public class ServerUser {
public class ServerUser implements Serializable {
private Long serverId;
private Long userId;

View File

@@ -4,11 +4,14 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class CachedAttachment {
public class CachedAttachment implements Serializable {
private String url;
private Long id;
private String proxyUrl;
private String fileName;
private Integer size;

View File

@@ -4,10 +4,12 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class CachedAuthor {
public class CachedAuthor implements Serializable {
private Long authorId;
private Boolean isBot;
}

View File

@@ -5,13 +5,14 @@ import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.EmbedType;
import java.io.Serializable;
import java.time.OffsetDateTime;
import java.util.List;
@Getter
@Setter
@Builder
public class CachedEmbed {
public class CachedEmbed implements Serializable {
private CachedEmbedAuthor author;
private CachedEmbedTitle title;
private CachedEmbedColor color;

View File

@@ -5,10 +5,12 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class CachedEmbedAuthor {
public class CachedEmbedAuthor implements Serializable {
private String name;
private String url;
private String avatar;

View File

@@ -4,10 +4,12 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Setter
@Getter
@Builder
public class CachedEmbedColor {
public class CachedEmbedColor implements Serializable {
private Integer r;
private Integer g;
private Integer b;

View File

@@ -4,10 +4,12 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class CachedEmbedField {
public class CachedEmbedField implements Serializable {
private String name;
private String value;
private Boolean inline;

View File

@@ -4,10 +4,12 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class CachedEmbedFooter {
public class CachedEmbedFooter implements Serializable {
private String text;
private String icon;
}

View File

@@ -3,8 +3,10 @@ package dev.sheldan.abstracto.core.models.cache;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter @Setter
public class CachedEmbedTitle {
public class CachedEmbedTitle implements Serializable {
private String title;
private String url;
}

View File

@@ -5,11 +5,13 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
@EqualsAndHashCode
public class CachedEmote {
public class CachedEmote implements Serializable {
private String emoteName;
private Long emoteId;
private Boolean external;

View File

@@ -4,10 +4,12 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class CachedImageInfo {
public class CachedImageInfo implements Serializable {
protected String url;
protected String proxyUrl;
protected Integer width;

View File

@@ -6,13 +6,14 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.Instant;
import java.util.List;
@Getter
@Setter
@Builder
public class CachedMessage {
public class CachedMessage implements Serializable {
private Long serverId;
private Long channelId;
private Long messageId;

View File

@@ -6,12 +6,13 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
@Getter
@Setter
@Builder
public class CachedReactions {
public class CachedReactions implements Serializable {
private CachedEmote emote;
private Boolean self;
private List<ServerUser> users;

View File

@@ -4,10 +4,12 @@ import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class CachedThumbnail {
public class CachedThumbnail implements Serializable {
protected String url;
protected String proxyUrl;
protected Integer width;

View File

@@ -3,6 +3,7 @@ package dev.sheldan.abstracto.core.service;
import dev.sheldan.abstracto.core.models.cache.*;
import net.dv8tion.jda.api.entities.*;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public interface CacheEntityService {
@@ -10,6 +11,7 @@ public interface CacheEntityService {
CachedEmote getCachedEmoteFromEmote(MessageReaction.ReactionEmote emote, Guild guild);
CachedAttachment getCachedAttachment(Message.Attachment attachment);
CachedEmbed getCachedEmbedFromEmbed(MessageEmbed embed);
List<CachedAttachment> getCachedAttachments(List<Message.Attachment> attachments);
CachedThumbnail buildCachedThumbnail(MessageEmbed.Thumbnail thumbnail);
CachedImageInfo buildCachedImage(MessageEmbed.ImageInfo image);
CompletableFuture<CachedReactions> getCachedReactionFromReaction(MessageReaction reaction);