discourse/app/assets/javascripts/admin/adapters/flagged-post.js.es6

39 lines
1.1 KiB
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import RestAdapter from "discourse/adapters/rest";
2017-09-11 16:44:20 -04:00
export default RestAdapter.extend({
pathFor(store, type, findArgs) {
let args = _.merge({ rest_api: true }, findArgs);
delete args.filter;
return `/admin/flags/${findArgs.filter}.json?${$.param(args)}`;
2017-09-11 16:44:20 -04:00
},
afterFindAll(results, helper) {
results.forEach(flag => {
let conversations = [];
flag.post_actions.forEach(pa => {
if (pa.conversation) {
let conversation = {
permalink: pa.permalink,
hasMore: pa.conversation.has_more,
response: {
excerpt: pa.conversation.response.excerpt,
2018-06-15 11:03:24 -04:00
user: helper.lookup("user", pa.conversation.response.user_id)
2017-09-11 16:44:20 -04:00
}
};
if (pa.conversation.reply) {
conversation.reply = {
excerpt: pa.conversation.reply.excerpt,
2018-06-15 11:03:24 -04:00
user: helper.lookup("user", pa.conversation.reply.user_id)
2017-09-11 16:44:20 -04:00
};
}
conversations.push(conversation);
}
});
2018-06-15 11:03:24 -04:00
flag.set("conversations", conversations);
2017-09-11 16:44:20 -04:00
});
return results;
}
});