mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-26 13:46:19 +00:00
[AB-240] changing invite filter to actively filter the server instead of only being based on the code
moving invite filter to separate module updating to newer liquibase version changing concept of immune roles which are directly associated to commands to immune roles which are immune against certain effects. these effects can be configured directly by the command (and a condition checks this effect), but they can be used in services as well, unrelated to commands adding checks to not execute message received listeners for the wrong message types adding metric support for 502 status fixing duplicating help entries when two module definitions with the same key are present
This commit is contained in:
@@ -8,6 +8,7 @@ import dev.sheldan.abstracto.core.service.GuildService;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatureDefinition;
|
||||
import dev.sheldan.abstracto.statistic.emote.service.TrackedEmoteService;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -35,7 +36,11 @@ public class EmoteTrackingListener implements AsyncMessageReceivedListener {
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(MessageReceivedModel model) {
|
||||
Map<Long, List<Emote>> collect = model.getMessage().getEmotesBag().stream().collect(Collectors.groupingBy(Emote::getIdLong));
|
||||
Message message = model.getMessage();
|
||||
if(!message.isFromGuild() || message.isWebhookMessage() || message.getType().isSystem()) {
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
Map<Long, List<Emote>> collect = message.getEmotesBag().stream().collect(Collectors.groupingBy(Emote::getIdLong));
|
||||
collect.values().forEach(groupedEmotes ->
|
||||
trackedEmoteService.addEmoteToRuntimeStorage(groupedEmotes.get(0), guildService.getGuildById(model.getServerId()), (long) groupedEmotes.size())
|
||||
);
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="statistic-tables/tables.xml" relativeToChangelogFile="true"/>
|
||||
<include file="statistic-seedData/data.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<property name="statisticModule" value="(SELECT id FROM module WHERE name = 'statistic')"/>
|
||||
<property name="emoteTrackingFeature" value="(SELECT id FROM feature WHERE key = 'emoteTracking')"/>
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="feature.xml" relativeToChangelogFile="true"/>
|
||||
<include file="module.xml" relativeToChangelogFile="true"/>
|
||||
<include file="emote_statistic_job.xml" relativeToChangelogFile="true"/>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="emote-statistic-job-insert">
|
||||
<insert tableName="scheduler_job">
|
||||
<column name="name" value="emoteStatisticJob"/>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="emote_tracking_feature-insertion">
|
||||
<insert tableName="feature">
|
||||
<column name="key" value="emoteTracking"/>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="statistic-module-insertion">
|
||||
<insert tableName="module">
|
||||
<column name="name" value="statistic"/>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="tracked_emote.xml" relativeToChangelogFile="true"/>
|
||||
<include file="used_emote.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="tracked_emote-table">
|
||||
<createTable tableName="tracked_emote">
|
||||
<column name="id" type="BIGINT" >
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="used_emote-table">
|
||||
<createTable tableName="used_emote">
|
||||
<column name="emote_id" type="BIGINT" >
|
||||
|
||||
@@ -257,6 +257,7 @@
|
||||
<xsd:attributeGroup name="changeLogAttributes">
|
||||
<xsd:attribute name="logicalFilePath" type="xsd:string"/>
|
||||
<xsd:attribute name="context" type="xsd:string"/>
|
||||
<xsd:attribute name="changeLogId" type="xsd:string"/>
|
||||
<xsd:attribute name="objectQuotingStrategy" type="objectQuotingStrategy" default="LEGACY"/>
|
||||
</xsd:attributeGroup>
|
||||
|
||||
@@ -277,11 +278,12 @@
|
||||
<xsd:attribute name="created" type="xsd:string"/>
|
||||
<xsd:attribute name="runOrder" type="xsd:string"/>
|
||||
<xsd:attribute name="ignore" type="booleanExp"/>
|
||||
<xsd:attribute name="runWith" type="xsd:string" />
|
||||
</xsd:attributeGroup>
|
||||
|
||||
<!-- Attributes for changes -->
|
||||
<xsd:attributeGroup name="changeAttributes">
|
||||
<xsd:anyAttribute namespace="##any" processContents="lax"/>
|
||||
<xsd:anyAttribute namespace="##other" processContents="lax"/>
|
||||
</xsd:attributeGroup>
|
||||
|
||||
<!-- Attributes for constraints -->
|
||||
@@ -306,7 +308,7 @@
|
||||
<xsd:attribute name="validateNullable" type="booleanExp"/>
|
||||
<xsd:attribute name="validateUnique" type="booleanExp"/>
|
||||
<xsd:attribute name="validatePrimaryKey" type="booleanExp"/>
|
||||
<xsd:attribute name="validateForeignKey " type="booleanExp"/>
|
||||
<xsd:attribute name="validateForeignKey" type="booleanExp"/>
|
||||
</xsd:attributeGroup>
|
||||
|
||||
<xsd:attributeGroup name="column">
|
||||
@@ -420,9 +422,10 @@
|
||||
<xsd:attribute name="incrementBy" type="xsd:string"/>
|
||||
<xsd:attribute name="maxValue" type="xsd:string"/>
|
||||
<xsd:attribute name="minValue" type="xsd:string"/>
|
||||
<xsd:attribute name="ordered" type="booleanExp"/>
|
||||
<xsd:attribute name="ordered" type="xsd:string"/>
|
||||
<xsd:attribute name="cacheSize" type="xsd:string"/>
|
||||
<xsd:attribute name="cycle" type="booleanExp">
|
||||
<xsd:attribute name="dataType" type="xsd:string" />
|
||||
<xsd:attribute name="cycle" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
true for a cycling sequence, false for a non-cycling sequence.
|
||||
@@ -481,11 +484,15 @@
|
||||
<xsd:attributeGroup ref="changeAttributes"/>
|
||||
<xsd:attributeGroup ref="tableNameAttribute"/>
|
||||
<xsd:attribute name="constraintName" type="xsd:string"/>
|
||||
<xsd:attribute name="dropIndex" type="booleanExp"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="addUniqueConstraint">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attributeGroup ref="changeAttributes"/>
|
||||
<xsd:attributeGroup ref="tableNameAttribute"/>
|
||||
<xsd:attribute name="columnNames" type="xsd:string"
|
||||
@@ -616,6 +623,7 @@
|
||||
<xsd:attribute name="header" type="xsd:string"/>
|
||||
<xsd:attribute name="name" type="xsd:string"/>
|
||||
<xsd:attribute name="type" type="xsd:string"/>
|
||||
<xsd:attribute name="allowUpdate" type="booleanExp"/>
|
||||
<xsd:attribute name="defaultValue" type="xsd:string"/>
|
||||
<xsd:attribute name="defaultValueNumeric" type="xsd:string"/>
|
||||
<xsd:attribute name="defaultValueDate" type="xsd:string"/>
|
||||
@@ -919,6 +927,7 @@
|
||||
<xsd:attribute name="schemaName" type="xsd:string"/>
|
||||
<xsd:attribute name="tableName" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="columnName" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="columnDataType" type="xsd:string"/>
|
||||
<xsd:attribute name="remarks" type="xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
@@ -957,6 +966,7 @@
|
||||
<xsd:attributeGroup ref="tableNameAttribute"/>
|
||||
<xsd:attribute name="tablespace" type="xsd:string"/>
|
||||
<xsd:attribute name="remarks" type="xsd:string"/>
|
||||
<xsd:anyAttribute namespace="##other" processContents="lax"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
@@ -1124,7 +1134,7 @@
|
||||
<xsd:complexType>
|
||||
<xsd:attributeGroup ref="changeAttributes"/>
|
||||
<xsd:attribute name="tag" type="xsd:string" use="required"/>
|
||||
|
||||
<xsd:anyAttribute namespace="##other" processContents="lax"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
@@ -1226,7 +1236,6 @@
|
||||
<xsd:complexType>
|
||||
<xsd:attributeGroup ref="changeAttributes"/>
|
||||
<xsd:attributeGroup ref="sequenceAttributes"/>
|
||||
<xsd:attribute name="dataType" type="xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
@@ -1283,7 +1292,7 @@
|
||||
</xsd:sequence>
|
||||
<xsd:attributeGroup ref="changeAttributes"/>
|
||||
<xsd:attribute name="class" type="xsd:string" use="required"/>
|
||||
|
||||
<xsd:anyAttribute processContents="lax" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
@@ -1374,4 +1383,4 @@
|
||||
</xsd:sequence>
|
||||
|
||||
</xsd:group>
|
||||
</xsd:schema>
|
||||
</xsd:schema>
|
||||
@@ -3,8 +3,8 @@
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog-3.8.xsd" >
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="1.0-statistic/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.sheldan.abstracto.statistic.emote.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedEmote;
|
||||
import dev.sheldan.abstracto.core.models.listener.MessageReceivedModel;
|
||||
import dev.sheldan.abstracto.core.service.GuildService;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatureDefinition;
|
||||
@@ -8,6 +7,7 @@ import dev.sheldan.abstracto.statistic.emote.service.TrackedEmoteService;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageType;
|
||||
import org.apache.commons.collections4.Bag;
|
||||
import org.apache.commons.collections4.bag.HashBag;
|
||||
import org.junit.Assert;
|
||||
@@ -17,9 +17,6 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -58,6 +55,7 @@ public class EmoteTrackingListenerTest {
|
||||
emotesBag.add(emote1);
|
||||
when(guildService.getGuildById(SERVER_ID)).thenReturn(guild);
|
||||
when(messageReceivedModel.getMessage()).thenReturn(message);
|
||||
setupMessage();
|
||||
when(messageReceivedModel.getServerId()).thenReturn(SERVER_ID);
|
||||
when(message.getEmotesBag()).thenReturn(emotesBag);
|
||||
testUnit.execute(messageReceivedModel);
|
||||
@@ -71,6 +69,7 @@ public class EmoteTrackingListenerTest {
|
||||
when(emote2.getIdLong()).thenReturn(EMOTE_ID);
|
||||
emotesBag.add(emote1);
|
||||
emotesBag.add(emote2);
|
||||
setupMessage();
|
||||
when(guildService.getGuildById(SERVER_ID)).thenReturn(guild);
|
||||
when(messageReceivedModel.getServerId()).thenReturn(SERVER_ID);
|
||||
when(messageReceivedModel.getMessage()).thenReturn(message);
|
||||
@@ -86,6 +85,7 @@ public class EmoteTrackingListenerTest {
|
||||
when(emote2.getIdLong()).thenReturn(EMOTE_ID + 1);
|
||||
emotesBag.add(emote1);
|
||||
emotesBag.add(emote2);
|
||||
setupMessage();
|
||||
when(guildService.getGuildById(SERVER_ID)).thenReturn(guild);
|
||||
when(messageReceivedModel.getServerId()).thenReturn(SERVER_ID);
|
||||
when(messageReceivedModel.getMessage()).thenReturn(message);
|
||||
@@ -99,10 +99,17 @@ public class EmoteTrackingListenerTest {
|
||||
public void testExecuteNoEmote() {
|
||||
when(message.getEmotesBag()).thenReturn(new HashBag<>());
|
||||
when(messageReceivedModel.getMessage()).thenReturn(message);
|
||||
setupMessage();
|
||||
testUnit.execute(messageReceivedModel);
|
||||
verify(trackedEmoteService, times(0)).addEmoteToRuntimeStorage(any(Emote.class), any(), anyLong());
|
||||
}
|
||||
|
||||
private void setupMessage() {
|
||||
when(message.isFromGuild()).thenReturn(true);
|
||||
when(message.isWebhookMessage()).thenReturn(false);
|
||||
MessageType type = MessageType.DEFAULT;
|
||||
when(message.getType()).thenReturn(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeature() {
|
||||
|
||||
Reference in New Issue
Block a user