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:
parent
d6cb1f6683
commit
b39119ace4
478 changed files with 21226 additions and 19495 deletions
|
@ -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,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue