sorting comments in post to config file
This commit is contained in:
parent
b90cb38550
commit
3814a67517
|
@ -27,6 +27,7 @@ const config = {
|
|||
searches: 600,
|
||||
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'],
|
||||
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) => {
|
||||
return new Promise(resolve => {
|
||||
(async () => {
|
||||
let validEmbedDomains = ['gfycat.com', 'youtube.com']
|
||||
let valid_embed_domains = ['gfycat.com', 'youtube.com']
|
||||
if(post_media || 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') {
|
||||
obj.has_media = true
|
||||
obj.media = {
|
||||
|
|
|
@ -503,7 +503,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||
}
|
||||
})()
|
||||
} 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 => {
|
||||
if(result.status === 200) {
|
||||
result.json()
|
||||
|
@ -724,7 +724,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||
console.log(`Redirecting to ${post_url} with cursor...`);
|
||||
return res.redirect(`${post_url}?cursor=${page}&page=${page}`)
|
||||
} 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())
|
||||
.then(result => {
|
||||
if(result.status === 200) {
|
||||
|
|
Loading…
Reference in New Issue