request blocked users with passport
This commit is contained in:
parent
cce2ad1f80
commit
389f447b5b
|
@ -61,6 +61,7 @@ const UserContextMenu = ({
|
|||
tabIndex={0}
|
||||
onClick={() => {
|
||||
dm(uid);
|
||||
// TODO if DM Channel with user already exist, just switch
|
||||
close();
|
||||
}}
|
||||
style={{ borderBottom: 'thin solid' }}
|
||||
|
|
|
@ -41,6 +41,11 @@ const include = [{
|
|||
'id',
|
||||
'name',
|
||||
],
|
||||
}, {
|
||||
model: RegUser,
|
||||
as: 'blocked',
|
||||
through: UserBlock,
|
||||
foreignKey: 'uid',
|
||||
}],
|
||||
}, {
|
||||
model: RegUser,
|
||||
|
|
|
@ -30,6 +30,7 @@ class User {
|
|||
this.ip = ip;
|
||||
this.channels = [];
|
||||
this.channelIds = [];
|
||||
this.blocked = [];
|
||||
this.ipSub = getIPv6Subnet(ip);
|
||||
this.wait = null;
|
||||
// following gets populated by passport
|
||||
|
@ -77,6 +78,15 @@ class User {
|
|||
]);
|
||||
}
|
||||
}
|
||||
if (reguser.blocked) {
|
||||
for (let i = 0; i < reguser.blocked.length; i += 1) {
|
||||
const {
|
||||
id,
|
||||
name,
|
||||
} = reguser.blocked[i];
|
||||
this.blocked.push([id, name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getName() {
|
||||
|
@ -194,6 +204,7 @@ class User {
|
|||
mailreg: !!(regUser.password),
|
||||
userlvl: this.isAdmin() ? 1 : 0,
|
||||
channels: this.channels,
|
||||
blocked: this.blocked,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ async function startDm(req: Request, res: Response) {
|
|||
errors.push('You are not logged in');
|
||||
}
|
||||
if (user && userId && user.id === userId) {
|
||||
errors.push('You can not start DM to yourself.');
|
||||
errors.push('You can not DM yourself.');
|
||||
}
|
||||
if (errors.length) {
|
||||
res.status(400);
|
||||
|
@ -118,6 +118,7 @@ async function startDm(req: Request, res: Response) {
|
|||
];
|
||||
await Promise.all(promises);
|
||||
|
||||
// TODO: inform websocket to add channelId to user
|
||||
res.json({
|
||||
channel: [
|
||||
ChannelId,
|
||||
|
|
Loading…
Reference in New Issue
Block a user