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) {
|
2017-09-14 11:58:11 -04:00
|
|
|
let args = _.merge({ rest_api: true }, findArgs);
|
2017-09-12 13:04:53 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|