mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-25 16:49:26 +01:00
sorting comments in post to config file
This commit is contained in:
parent
b90cb38550
commit
3814a67517
@ -27,6 +27,7 @@ const config = {
|
|||||||
searches: 600,
|
searches: 600,
|
||||||
sidebar: 60 * 60 * 24 * 7 // 7 days
|
sidebar: 60 * 60 * 24 * 7 // 7 days
|
||||||
},
|
},
|
||||||
|
post_comments_sort: 'confidence', // one of: confidence, top, new, controversial, old, random, qa, live
|
||||||
valid_media_domains: ['preview.redd.it', 'external-preview.redd.it', 'i.redd.it', 'v.redd.it', 'a.thumbs.redditmedia.com', 'b.thumbs.redditmedia.com', 'thumbs.gfycat.com', 'i.ytimg.com'],
|
valid_media_domains: ['preview.redd.it', 'external-preview.redd.it', 'i.redd.it', 'v.redd.it', 'a.thumbs.redditmedia.com', 'b.thumbs.redditmedia.com', 'thumbs.gfycat.com', 'i.ytimg.com'],
|
||||||
reddit_api_error_text: `Seems like your instance is either blocked (e.g. due to API rate limiting), reddit is currently down, or your API key is expired and not renewd properly. This can also happen for other reasons.`
|
reddit_api_error_text: `Seems like your instance is either blocked (e.g. due to API rate limiting), reddit is currently down, or your API key is expired and not renewd properly. This can also happen for other reasons.`
|
||||||
};
|
};
|
||||||
|
@ -2,10 +2,10 @@ module.exports = function() {
|
|||||||
this.processPostMedia = (obj, post, post_media, has_gif, reddit_video, gif_to_mp4) => {
|
this.processPostMedia = (obj, post, post_media, has_gif, reddit_video, gif_to_mp4) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
(async () => {
|
(async () => {
|
||||||
let validEmbedDomains = ['gfycat.com', 'youtube.com']
|
let valid_embed_domains = ['gfycat.com', 'youtube.com']
|
||||||
if(post_media || has_gif) {
|
if(post_media || has_gif) {
|
||||||
if(!has_gif) {
|
if(!has_gif) {
|
||||||
if(validEmbedDomains.includes(post_media.type)) {
|
if(valid_embed_domains.includes(post_media.type)) {
|
||||||
if(post_media.type === 'gfycat.com') {
|
if(post_media.type === 'gfycat.com') {
|
||||||
obj.has_media = true
|
obj.has_media = true
|
||||||
obj.media = {
|
obj.media = {
|
||||||
|
@ -503,7 +503,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
} else {
|
} else {
|
||||||
fetch(`https://oauth.reddit.com${comments_url}?api_type=json&context=${context}`, redditApiGETHeaders())
|
fetch(`https://oauth.reddit.com${comments_url}?api_type=json&sort=${config.post_comments_sort}&context=${context}`, redditApiGETHeaders())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if(result.status === 200) {
|
if(result.status === 200) {
|
||||||
result.json()
|
result.json()
|
||||||
@ -724,7 +724,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||||||
console.log(`Redirecting to ${post_url} with cursor...`);
|
console.log(`Redirecting to ${post_url} with cursor...`);
|
||||||
return res.redirect(`${post_url}?cursor=${page}&page=${page}`)
|
return res.redirect(`${post_url}?cursor=${page}&page=${page}`)
|
||||||
} else {
|
} else {
|
||||||
let url = `https://oauth.reddit.com/api/morechildren?api_type=json&children=${ids_to_show}&limit_children=false&link_id=t3_${post_id}&sort=confidence`
|
let url = `https://oauth.reddit.com/api/morechildren?api_type=json&children=${ids_to_show}&limit_children=false&link_id=t3_${post_id}&sort=${config.post_comments_sort}`
|
||||||
fetch(url, redditApiGETHeaders())
|
fetch(url, redditApiGETHeaders())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if(result.status === 200) {
|
if(result.status === 200) {
|
||||||
|
Loading…
Reference in New Issue
Block a user