1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-23 07:09:44 +02:00

Project managers, board members, auto-update after reconnection, refactoring

This commit is contained in:
Maksim Eltyshev 2021-06-24 01:05:22 +05:00
parent d6cb1f6683
commit b39119ace4
478 changed files with 21226 additions and 19495 deletions

View file

@ -1,16 +1,44 @@
module.exports = {
async fn(inputs, exits) {
// TODO: allow over HTTP without subscription
if (!this.req.isSocket) {
return this.res.badRequest();
}
const { currentUser } = this.req;
sails.sockets.join(this.req, `user:${currentUser.id}`); // TODO: only when subscription needed
return exits.success({
item: currentUser,
});
const Errors = {
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
};
const CURRENT_USER_ID = 'me';
module.exports = {
inputs: {
id: {
type: 'string',
regex: /^[0-9]+|me$/,
required: true,
},
},
exits: {
boardNotFound: {
responseType: 'notFound',
},
},
async fn(inputs) {
let user;
if (inputs.id === CURRENT_USER_ID) {
({ currentUser: user } = this.req);
if (this.req.isSocket) {
sails.sockets.join(this.req, `user:${user.id}`); // TODO: only when subscription needed
}
} else {
user = await sails.helpers.users.getOne(inputs.id);
if (!user) {
throw Errors.USER_NOT_FOUND;
}
}
return {
item: user,
};
},
};