mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Add feed retention configuration option. (#174)
This commit is contained in:
parent
69504eb808
commit
8880a884c3
3 changed files with 27 additions and 23 deletions
|
@ -26,6 +26,9 @@ COMPROMISED_PASSWORD_CHECK: true
|
|||
# Disable Registration
|
||||
DISABLE_REGISTRATION: false
|
||||
|
||||
# Feed Retention Time in Days
|
||||
FEED_RETENTION: 30
|
||||
|
||||
# Hibernate properties
|
||||
hibernate.connection.url: jdbc:postgresql://postgres:5432/piped
|
||||
hibernate.connection.driver_class: org.postgresql.Driver
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
package me.kavin.piped;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.activej.inject.Injector;
|
||||
import me.kavin.piped.consts.Constants;
|
||||
import me.kavin.piped.utils.DatabaseSessionFactory;
|
||||
import me.kavin.piped.utils.DownloaderImpl;
|
||||
import me.kavin.piped.utils.Multithreading;
|
||||
import me.kavin.piped.utils.ResponseHelper;
|
||||
import me.kavin.piped.utils.obj.db.PubSub;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.query.Query;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
|
||||
import io.activej.inject.Injector;
|
||||
import me.kavin.piped.utils.DatabaseSessionFactory;
|
||||
import me.kavin.piped.utils.DownloaderImpl;
|
||||
import me.kavin.piped.utils.Multithreading;
|
||||
import me.kavin.piped.utils.ResponseHelper;
|
||||
import me.kavin.piped.utils.obj.db.PubSub;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Main {
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class Main {
|
|||
tr.begin();
|
||||
|
||||
Query<?> query = s.createQuery("delete from Video where uploaded < :time").setParameter("time",
|
||||
System.currentTimeMillis() - TimeUnit.DAYS.toMillis(10));
|
||||
System.currentTimeMillis() - TimeUnit.DAYS.toMillis(Constants.FEED_RETENTION));
|
||||
|
||||
System.out.println(String.format("Cleanup: Removed %o old videos", query.executeUpdate()));
|
||||
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package me.kavin.piped.consts;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import me.kavin.piped.utils.PageMixin;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.Page;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ProxySelector;
|
||||
|
@ -9,16 +17,6 @@ import java.net.http.HttpClient.Redirect;
|
|||
import java.net.http.HttpClient.Version;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.Page;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import me.kavin.piped.utils.PageMixin;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0";
|
||||
|
@ -45,6 +43,8 @@ public class Constants {
|
|||
|
||||
public static final boolean DISABLE_REGISTRATION;
|
||||
|
||||
public static final int FEED_RETENTION;
|
||||
|
||||
public static final ObjectMapper mapper = new ObjectMapper().addMixIn(Page.class, PageMixin.class);
|
||||
|
||||
public static final Object2ObjectOpenHashMap<String, String> hibernateProperties = new Object2ObjectOpenHashMap<>();
|
||||
|
@ -66,6 +66,7 @@ public class Constants {
|
|||
FRONTEND_URL = getProperty(prop, "FRONTEND_URL", "https://piped.kavin.rocks");
|
||||
COMPROMISED_PASSWORD_CHECK = Boolean.parseBoolean(getProperty(prop, "COMPROMISED_PASSWORD_CHECK", "true"));
|
||||
DISABLE_REGISTRATION = Boolean.parseBoolean(getProperty(prop, "DISABLE_REGISTRATION", "false"));
|
||||
FEED_RETENTION = Integer.parseInt(getProperty(prop, "FEED_RETENTION", "30"));
|
||||
System.getenv().forEach((key, value) -> {
|
||||
if (key.startsWith("hibernate"))
|
||||
hibernateProperties.put(key, value);
|
||||
|
|
Loading…
Reference in a new issue