feat(app, plugins): expose q for custom templates and users handle in 3rd party plugins (#633)
This commit is contained in:
@@ -26,7 +26,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
|
||||
//Initialization
|
||||
const pending = []
|
||||
const {queries} = conf
|
||||
const data = {animated:true, large:false, base:{}, config:{}, errors:[], plugins:{}, computed:{}}
|
||||
const data = {q, animated:true, large:false, base:{}, config:{}, errors:[], plugins:{}, computed:{}}
|
||||
const imports = {
|
||||
plugins:Plugins,
|
||||
templates:Templates,
|
||||
|
||||
@@ -10,7 +10,7 @@ export default async function({login, data, queries, imports, q, account}, {enab
|
||||
let {limit, "limit.characters":limit_characters, medias, sections, shuffle, user} = imports.metadata.plugins.anilist.inputs({data, account, q})
|
||||
|
||||
//Initialization
|
||||
const result = {user:{stats:null, genres:[]}, lists:Object.fromEntries(medias.map(type => [type, {}])), characters:[], sections}
|
||||
const result = {user:{name:user, stats:null, genres:[]}, lists:Object.fromEntries(medias.map(type => [type, {}])), characters:[], sections}
|
||||
|
||||
//User statistics
|
||||
for (let retried = false; !retried; retried = true) {
|
||||
|
||||
@@ -415,7 +415,7 @@ export default async function({login, imports, data, q, account}, {enabled = fal
|
||||
track.artwork = await imports.imgb64(track.artwork)
|
||||
}
|
||||
//Save results
|
||||
return {...raw, tracks, played_at}
|
||||
return {...raw, user, tracks, played_at}
|
||||
}
|
||||
|
||||
//Unhandled error
|
||||
|
||||
@@ -47,7 +47,7 @@ export default async function({login, data, imports, q, queries, account}, {enab
|
||||
posts = await Promise.all(posts.map(async ({image, ...post}) => ({image:await imports.imgb64(image, {width:144, height:-1}), ...post})))
|
||||
}
|
||||
//Results
|
||||
return {source, link, descriptions, covers, list:posts}
|
||||
return {user, source, link, descriptions, covers, list:posts}
|
||||
}
|
||||
|
||||
//Unhandled error
|
||||
|
||||
@@ -24,7 +24,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
||||
const {data:{items:[{reputation, badge_counts:{bronze, silver, gold}, answer_count:answers, question_count:questions, view_count:views}]}} = await imports.axios.get(`${api.user}?site=stackoverflow&filter=${filters.user}`)
|
||||
const {data:{total:comments}} = await imports.axios.get(`${api.user}/comments?site=stackoverflow&filter=total`)
|
||||
//Save result
|
||||
result.user = {reputation, badges:bronze + silver + gold, questions, answers, comments, views}
|
||||
result.user = {id:user, reputation, badges:bronze + silver + gold, questions, answers, comments, views}
|
||||
}
|
||||
|
||||
//Answers
|
||||
|
||||
Reference in New Issue
Block a user