mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-16 20:29:08 +00:00
[AB-285] fixing interval of warn decay job
removing has example config from unban enabling to change the configuration for cron scheduler job adding HTTP method to okhttp logger fixing unmute job parameters changing to use cache when retrieving reactions for a message to cache it
This commit is contained in:
@@ -42,7 +42,7 @@ public class UnBan extends AbstractConditionableCommand {
|
||||
public CommandConfiguration getConfiguration() {
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
parameters.add(Parameter.builder().name("user").templated(true).type(User.class).build());
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).hasExample(true).build();
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("unBan")
|
||||
.module(ModerationModuleDefinition.MODERATION)
|
||||
|
||||
@@ -207,8 +207,8 @@ public class MuteServiceBean implements MuteService {
|
||||
} else {
|
||||
log.debug("Starting scheduled job to execute unMute.");
|
||||
HashMap<Object, Object> parameters = new HashMap<>();
|
||||
parameters.put("muteId", muteId);
|
||||
parameters.put("serverId", serverId);
|
||||
parameters.put("muteId", muteId.toString());
|
||||
parameters.put("serverId", serverId.toString());
|
||||
JobParameters jobParameters = JobParameters.builder().parameters(parameters).build();
|
||||
return schedulerService.executeJobWithParametersOnce("unMuteJob", "moderation", jobParameters, Date.from(unMuteDate));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
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.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="update/update.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
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.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="warn_decay_job.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
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.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="warn-decay-job-update_schedule">
|
||||
<update tableName="scheduler_job">
|
||||
<column name="cron_expression" value="0 0 0 * * ?"/>
|
||||
<where>name='warnDecayJob'</where>
|
||||
</update>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
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.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="warn-decay-job-update_schedule">
|
||||
<update tableName="scheduler_job">
|
||||
<column name="cron_expression" value="0 0 0 * * ?"/>
|
||||
<where>name='warnDecayJob'</where>
|
||||
</update>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -9,4 +9,5 @@
|
||||
<include file="1.0-moderation/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.11-moderation/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.15/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.16/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -14,7 +14,7 @@ public class OkHttpLogger implements Interceptor {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
log.debug("Executing request towards towards {}.", request.url().toString());
|
||||
log.debug("Executing request of method {} towards towards {}.", request.method(), request.url().toString());
|
||||
Response response = chain.proceed(request);
|
||||
long startTime = response.sentRequestAtMillis();
|
||||
long endTime = response.receivedResponseAtMillis();
|
||||
|
||||
@@ -165,7 +165,7 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
@Override
|
||||
public CompletableFuture<CachedReactions> getCachedReactionFromReaction(MessageReaction reaction) {
|
||||
CompletableFuture<CachedReactions> future = new CompletableFuture<>();
|
||||
ReactionPaginationAction users = reaction.retrieveUsers().cache(false);
|
||||
ReactionPaginationAction users = reaction.retrieveUsers();
|
||||
CachedReactions.CachedReactionsBuilder builder = CachedReactions.builder();
|
||||
|
||||
List<ServerUser> aUsers = new ArrayList<>();
|
||||
|
||||
@@ -67,9 +67,20 @@ public class SchedulerServiceBean implements SchedulerService {
|
||||
} else {
|
||||
scheduler.addJob(jobDetail, true);
|
||||
}
|
||||
} else {
|
||||
if(isRecurringJob(schedulerJob)) {
|
||||
jobDetail = scheduleCreator.createJob((Class<? extends QuartzJobBean>) Class.forName(schedulerJob.getClazz()),
|
||||
true, context, schedulerJob.getName(), schedulerJob.getGroupName(), schedulerJob.isRecovery());
|
||||
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobDetail.getKey());
|
||||
|
||||
Trigger trigger = scheduleCreator.createBasicCronTrigger(new Date(),
|
||||
schedulerJob.getCronExpression());
|
||||
scheduler.rescheduleJob(triggers.get(0).getKey(), trigger);
|
||||
log.info("Rescheduling job {}, its a cron job and the definition might have changed.", schedulerJob.getName());
|
||||
} else {
|
||||
log.info("Not scheduling job {}, because it was already scheduled.", schedulerJob.getName());
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException | SchedulerException e) {
|
||||
log.error("Failed to schedule job", e);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class SchedulerStartupService {
|
||||
@Transactional(isolation = Isolation.SERIALIZABLE)
|
||||
public void handleContextRefreshEvent(ContextRefreshedEvent ctxStartEvt) {
|
||||
schedulerJobManagementServiceBean.findAll().forEach(schedulerJob -> {
|
||||
if(!schedulerJobManagementServiceBean.doesJobExist(schedulerJob) || !schedulerJobManagementServiceBean.isJobDefinitionTheSame(schedulerJob)) {
|
||||
if(!schedulerJobManagementServiceBean.doesJobExist(schedulerJob)) {
|
||||
schedulerJobManagementServiceBean.createOrUpdate(schedulerJob);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user