mirror of
https://github.com/wassname/talk.git
synced 2026-09-10 12:43:11 +08:00
remove redundant endpoint
This commit is contained in:
@@ -31,8 +31,8 @@ export const saveBio = (user_id, formData) => dispatch => {
|
|||||||
export const fetchCommentsByUserId = userId => {
|
export const fetchCommentsByUserId = userId => {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch({type: actions.REQUEST_COMMENTS_BY_USER});
|
dispatch({type: actions.REQUEST_COMMENTS_BY_USER});
|
||||||
return coralApi(`/comments/user/${userId}`)
|
return coralApi(`/comments?user_id${userId}`)
|
||||||
.then(comments => {
|
.then(({comments}) => {
|
||||||
comments.forEach(comment => {
|
comments.forEach(comment => {
|
||||||
dispatch(addItem(comment, 'comments'));
|
dispatch(addItem(comment, 'comments'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ router.get('/', authorization.needed('admin'), (req, res, next) => {
|
|||||||
const {
|
const {
|
||||||
status = null,
|
status = null,
|
||||||
action_type = null,
|
action_type = null,
|
||||||
asset_id = null
|
asset_id = null,
|
||||||
|
user_id = null
|
||||||
} = req.query;
|
} = req.query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,6 +33,8 @@ router.get('/', authorization.needed('admin'), (req, res, next) => {
|
|||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
query = assetIDWrap(Comment.findByStatus(status === 'new' ? null : status));
|
query = assetIDWrap(Comment.findByStatus(status === 'new' ? null : status));
|
||||||
|
} else if (user_id) {
|
||||||
|
query = Comment.findByUserId(user_id);
|
||||||
} else if (action_type) {
|
} else if (action_type) {
|
||||||
query = Comment
|
query = Comment
|
||||||
.findIdsByActionType(action_type)
|
.findIdsByActionType(action_type)
|
||||||
@@ -121,18 +124,6 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/user/:user_id', (req, res, next) => {
|
|
||||||
// how to only get YOUR comments?
|
|
||||||
Comment.findByUserId(req.params.user_id)
|
|
||||||
.then(comments => {
|
|
||||||
res.json(comments);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
error.status = 500;
|
|
||||||
next(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/:comment_id', authorization.needed('admin'), (req, res, next) => {
|
router.get('/:comment_id', authorization.needed('admin'), (req, res, next) => {
|
||||||
Comment
|
Comment
|
||||||
.findById(req.params.comment_id)
|
.findById(req.params.comment_id)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function storageMock() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
global.document = jsdom(fs.readFileSync(path.resolve(__dirname, '/index.test.html')));
|
global.document = jsdom(fs.readFileSync(path.resolve(__dirname, 'index.test.html')));
|
||||||
global.window = document.defaultView;
|
global.window = document.defaultView;
|
||||||
|
|
||||||
// these lines are required for react-mdl
|
// these lines are required for react-mdl
|
||||||
|
|||||||
Reference in New Issue
Block a user