feat: Added Emoji caching with cleanup and TTL#1523
Conversation
|
|
| // MessageId with a Map of Emojis and reacted users | ||
| // <MessageId, Map<Emoji, Set<UserId>>> | ||
| private final Map<Long, Map<String, Set<Long>>> reactions = new ConcurrentHashMap<>(); | ||
| private final String TJ_BOT_USER_ID = "884898473676271646"; |
There was a problem hiding this comment.
that wont work. what u want is probably sth like jda.getSelfBot(), i guess
There was a problem hiding this comment.
With no ref to jda, how would I do this?
There was a problem hiding this comment.
Pass the reference to the constructor and pass jda from Features.java
There was a problem hiding this comment.
getJda() exists on any JDA class. Such as all the event classes.
There was a problem hiding this comment.
You can search for selfbot in the repo and will find plenty of examples :)
| // MessageId with a Map of Emojis and reacted users | ||
| // <MessageId, Map<Emoji, Set<UserId>>> | ||
| private final Map<Long, Map<String, Set<Long>>> reactions = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
create a Record to represent what ur doing here and get rid of the 2d-map. do you have two keys or two values? put those into a record respectively.
There was a problem hiding this comment.
The initial key is the message ID, then that value is a Map with the emoji as the key, and reacted userIDs as the value
There was a problem hiding this comment.
thats not what i mean. im asking about your access patterns to the map. can you use a Map<MessageAndEmoji, User> or would you need a Map<Message, EmojiAndUser> or neither?
Signed-off-by: Glabay <Java_Guru@live.com>
Signed-off-by: Glabay <Java_Guru@live.com>
Signed-off-by: Glabay <Java_Guru@live.com>
Signed-off-by: Glabay <Java_Guru@live.com>
Signed-off-by: Glabay <Java_Guru@live.com>
| repositories.add(githubApi.getRepositoryById(repoId)); | ||
| } | ||
| } catch (IOException ex) { | ||
| } catch (NoSuchFieldError | IOException ex) { |
There was a problem hiding this comment.
where are all these changes coming from. please keep ur PR focused and dont touch "the entire codebase".
There was a problem hiding this comment.
This came from upgrading the JDA to latest version
Zabuzard
left a comment
There was a problem hiding this comment.
the PR in its current state is quite chaotic. it contains WAY too much unrelated changes. also, a full JDA update - that defiinitely does not belong in here at all
This replaces the old way of handling reacted messages, keeping track in a local mem cache for 7 days, with an hourly cleanup routine. Using existing information from the original event, no additional REST calls are needed.
Test for validations included with the work