mirror of
https://github.com/wassname/talk.git
synced 2026-07-15 11:26:58 +08:00
Merge branch 'master' into subscribe-mod-actions
Conflicts: client/coral-admin/src/routes/Moderation/components/Moderation.js client/coral-admin/src/routes/Moderation/components/styles.css client/coral-admin/src/routes/Moderation/containers/Moderation.js
This commit is contained in:
@@ -19,6 +19,16 @@ const genAssetsByID = (context, ids) => AssetModel.find({
|
||||
}
|
||||
}).then(util.singleJoinBy(ids, 'id'));
|
||||
|
||||
/**
|
||||
* [getAssetsByQuery description]
|
||||
* @param {Object} context the context of the request
|
||||
* @param {Object} query the query
|
||||
* @return {Promise} resolves the assets
|
||||
*/
|
||||
const getAssetsByQuery = (context, query) => {
|
||||
return AssetsService.search(query);
|
||||
};
|
||||
|
||||
/**
|
||||
* This endpoint find or creates an asset at the given url when it is loaded.
|
||||
* @param {Object} context the context of the request
|
||||
@@ -65,6 +75,7 @@ module.exports = (context) => ({
|
||||
// this operation create a new asset if one isn't found.
|
||||
getByURL: (url) => findOrCreateAssetByURL(context, url),
|
||||
|
||||
search: (query) => getAssetsByQuery(context, query),
|
||||
getByID: new DataLoader((ids) => genAssetsByID(context, ids)),
|
||||
getForMetrics: () => getAssetsForMetrics(context),
|
||||
getAll: new util.SingletonResolver(() => AssetModel.find({}))
|
||||
|
||||
@@ -6,12 +6,12 @@ const {
|
||||
} = require('../../perms/constants');
|
||||
|
||||
const RootQuery = {
|
||||
assets(_, args, {loaders: {Assets}, user}) {
|
||||
assets(_, {query}, {loaders: {Assets}, user}) {
|
||||
if (user == null || !user.can(SEARCH_ASSETS)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Assets.getAll.load();
|
||||
return Assets.search(query);
|
||||
},
|
||||
asset(_, query, {loaders: {Assets}}) {
|
||||
if (query.id) {
|
||||
|
||||
@@ -104,7 +104,15 @@ input UsersQuery {
|
||||
sort: SORT_ORDER = REVERSE_CHRONOLOGICAL
|
||||
}
|
||||
|
||||
# AssetsQuery allows teh ability to query assets by specific fields
|
||||
input AssetsQuery {
|
||||
|
||||
# a search string to match against titles, authors, urls, etc.
|
||||
value: String = ""
|
||||
|
||||
# Limit the number of results to be returned
|
||||
limit: Int = 10
|
||||
}
|
||||
################################################################################
|
||||
## Tags
|
||||
################################################################################
|
||||
@@ -635,7 +643,7 @@ type RootQuery {
|
||||
comment(id: ID!): Comment
|
||||
|
||||
# All assets. Requires the `ADMIN` role.
|
||||
assets: [Asset]
|
||||
assets(query: AssetsQuery): [Asset]
|
||||
|
||||
# Find or create an asset by url, or just find with the ID.
|
||||
asset(id: ID, url: String): Asset
|
||||
|
||||
Reference in New Issue
Block a user