mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Support multiple newleaf urls
This commit is contained in:
parent
1e5849f504
commit
ec081cf0c5
7 changed files with 10 additions and 10 deletions
|
@ -4,7 +4,7 @@
|
|||
"port": 80,
|
||||
"globalSalt": "[global salt (pepper) that is added to every ip before hashing to make it even harder for someone to decode the ip]",
|
||||
"adminUserID": "[the hashed id of the user who can perform admin actions]",
|
||||
"newLeafURL": "http://localhost:3241",
|
||||
"newLeafURLs": ["http://localhost:3241"],
|
||||
"discordReportChannelWebhookURL": null, //URL from discord if you would like notifications when someone makes a report [optional]
|
||||
"discordFirstTimeSubmissionsWebhookURL": null, //URL from discord if you would like notifications when someone makes a first time submission [optional]
|
||||
"discordCompletelyIncorrectReportWebhookURL": null, //URL from discord if you would like notifications when someone reports a submission as completely incorrect [optional]
|
||||
|
|
|
@ -44,7 +44,7 @@ addDefaults(config, {
|
|||
},
|
||||
},
|
||||
userCounterURL: null,
|
||||
newLeafURL: null,
|
||||
newLeafURLs: null,
|
||||
maxRewardTimePerSegmentInSeconds: 86400,
|
||||
postgres: null,
|
||||
dumpDatabase: {
|
||||
|
|
|
@ -265,7 +265,7 @@ async function autoModerateSubmission(apiVideoInfo: APIVideoInfo,
|
|||
}
|
||||
|
||||
async function getYouTubeVideoInfo(videoID: VideoID, ignoreCache = false): Promise<APIVideoInfo> {
|
||||
if (config.newLeafURL !== null) {
|
||||
if (config.newLeafURLs !== null) {
|
||||
return YouTubeAPI.listVideos(videoID, ignoreCache);
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -57,10 +57,10 @@ async function sendWebhooks(voteData: VoteData) {
|
|||
webhookURL = config.discordCompletelyIncorrectReportWebhookURL;
|
||||
}
|
||||
|
||||
if (config.newLeafURL !== null) {
|
||||
if (config.newLeafURLs !== null) {
|
||||
const { err, data } = await YouTubeAPI.listVideos(submissionInfoRow.videoID);
|
||||
if (err) return;
|
||||
|
||||
|
||||
const isUpvote = voteData.incrementAmount > 0;
|
||||
// Send custom webhooks
|
||||
dispatchEvent(isUpvote ? "vote.up" : "vote.down", {
|
||||
|
|
|
@ -6,7 +6,7 @@ export interface SBSConfig {
|
|||
mockPort?: number;
|
||||
globalSalt: string;
|
||||
adminUserID: string;
|
||||
newLeafURL?: string;
|
||||
newLeafURLs?: string[];
|
||||
discordReportChannelWebhookURL?: string;
|
||||
discordFirstTimeSubmissionsWebhookURL?: string;
|
||||
discordCompletelyIncorrectReportWebhookURL?: string;
|
||||
|
|
|
@ -21,15 +21,15 @@ export class YouTubeAPI {
|
|||
}
|
||||
}
|
||||
|
||||
if (!config.newLeafURL) return {err: "NewLeaf URL not found", data: null};
|
||||
if (!config.newLeafURLs || config.newLeafURLs.length <= 0) return {err: "NewLeaf URL not found", data: null};
|
||||
|
||||
try {
|
||||
const result = await fetch(config.newLeafURL + "/api/v1/videos/" + videoID, { method: "GET" });
|
||||
const result = await fetch(config.newLeafURLs[Math.floor(Math.random() * config.newLeafURLs.length)] + "/api/v1/videos/" + videoID, { method: "GET" });
|
||||
|
||||
if (result.ok) {
|
||||
const data = await result.json();
|
||||
if (data.error) {
|
||||
Logger.warn("CloudTube API Error: " + data.error)
|
||||
Logger.warn("NewLeaf API Error: " + data.error)
|
||||
return { err: data.error, data: null };
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"mockPort": 8081,
|
||||
"globalSalt": "testSalt",
|
||||
"adminUserID": "testUserId",
|
||||
"newLeafURL": "placeholder",
|
||||
"newLeafURLs": ["placeholder"],
|
||||
"discordReportChannelWebhookURL": "http://127.0.0.1:8081/ReportChannelWebhook",
|
||||
"discordFirstTimeSubmissionsWebhookURL": "http://127.0.0.1:8081/FirstTimeSubmissionsWebhook",
|
||||
"discordCompletelyIncorrectReportWebhookURL": "http://127.0.0.1:8081/CompletelyIncorrectReportWebhook",
|
||||
|
|
Loading…
Reference in a new issue