mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Use a limited threadpool for handling pubsub requests.
This commit is contained in:
parent
1dbda14335
commit
f9289a05d1
1 changed files with 7 additions and 4 deletions
|
@ -76,18 +76,21 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
||||||
.map(GET, "/webhooks/pubsub", AsyncServlet.ofBlocking(executor, request -> {
|
.map(GET, "/webhooks/pubsub", AsyncServlet.ofBlocking(executor, request -> {
|
||||||
var topic = request.getQueryParameter("hub.topic");
|
var topic = request.getQueryParameter("hub.topic");
|
||||||
if (topic != null)
|
if (topic != null)
|
||||||
Multithreading.runAsync(() -> {
|
Multithreading.runAsyncLimited(() -> {
|
||||||
String channelId = StringUtils.substringAfter(topic, "channel_id=");
|
String channelId = StringUtils.substringAfter(topic, "channel_id=");
|
||||||
PubSubHelper.updatePubSub(channelId);
|
PubSubHelper.updatePubSub(channelId);
|
||||||
});
|
});
|
||||||
return HttpResponse.ok200().withPlainText(Objects.requireNonNull(request.getQueryParameter("hub.challenge")));
|
|
||||||
|
var challenge = request.getQueryParameter("hub.challenge");
|
||||||
|
return HttpResponse.ok200()
|
||||||
|
.withPlainText(Objects.requireNonNullElse(challenge, "ok"));
|
||||||
})).map(POST, "/webhooks/pubsub", AsyncServlet.ofBlocking(executor, request -> {
|
})).map(POST, "/webhooks/pubsub", AsyncServlet.ofBlocking(executor, request -> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
SyndFeed feed = new SyndFeedInput().build(
|
SyndFeed feed = new SyndFeedInput().build(
|
||||||
new InputSource(new ByteArrayInputStream(request.loadBody().getResult().asArray())));
|
new InputSource(new ByteArrayInputStream(request.loadBody().getResult().asArray())));
|
||||||
|
|
||||||
Multithreading.runAsync(() -> {
|
Multithreading.runAsyncLimited(() -> {
|
||||||
for (var entry : feed.getEntries()) {
|
for (var entry : feed.getEntries()) {
|
||||||
String url = entry.getLinks().get(0).getHref();
|
String url = entry.getLinks().get(0).getHref();
|
||||||
String videoId = StringUtils.substring(url, -11);
|
String videoId = StringUtils.substring(url, -11);
|
||||||
|
@ -95,7 +98,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
||||||
if (DatabaseHelper.doesVideoExist(s, videoId))
|
if (DatabaseHelper.doesVideoExist(s, videoId))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Multithreading.runAsync(() -> {
|
Multithreading.runAsyncLimited(() -> {
|
||||||
try {
|
try {
|
||||||
Sentry.setExtra("videoId", videoId);
|
Sentry.setExtra("videoId", videoId);
|
||||||
var extractor = YOUTUBE_SERVICE.getStreamExtractor("https://youtube.com/watch?v=" + videoId);
|
var extractor = YOUTUBE_SERVICE.getStreamExtractor("https://youtube.com/watch?v=" + videoId);
|
||||||
|
|
Loading…
Reference in a new issue