forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request RocketChat#7195 from RocketChat/fix-missing-i18n
[FIX] Fix emoji picker translations Add leader role and "Chat With" section at top of chat
- Loading branch information
Showing
14 changed files
with
270 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Meteor.methods({ | ||
addRoomLeader(rid, userId) { | ||
check(rid, String); | ||
check(userId, String); | ||
|
||
if (!Meteor.userId()) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
method: 'addRoomLeader' | ||
}); | ||
} | ||
|
||
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'set-leader', rid)) { | ||
throw new Meteor.Error('error-not-allowed', 'Not allowed', { | ||
method: 'addRoomLeader' | ||
}); | ||
} | ||
|
||
const user = RocketChat.models.Users.findOneById(userId); | ||
|
||
if (!user || !user.username) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
method: 'addRoomLeader' | ||
}); | ||
} | ||
|
||
const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, user._id); | ||
|
||
if (!subscription) { | ||
throw new Meteor.Error('error-user-not-in-room', 'User is not in this room', { | ||
method: 'addRoomLeader' | ||
}); | ||
} | ||
|
||
if (Array.isArray(subscription.roles) === true && subscription.roles.includes('leader') === true) { | ||
throw new Meteor.Error('error-user-already-leader', 'User is already a leader', { | ||
method: 'addRoomLeader' | ||
}); | ||
} | ||
|
||
RocketChat.models.Subscriptions.addRoleById(subscription._id, 'leader'); | ||
|
||
const fromUser = RocketChat.models.Users.findOneById(Meteor.userId()); | ||
|
||
RocketChat.models.Messages.createSubscriptionRoleAddedWithRoomIdAndUser(rid, user, { | ||
u: { | ||
_id: fromUser._id, | ||
username: fromUser.username | ||
}, | ||
role: 'leader' | ||
}); | ||
|
||
if (RocketChat.settings.get('UI_DisplayRoles')) { | ||
RocketChat.Notifications.notifyLogged('roles-change', { | ||
type: 'added', | ||
_id: 'leader', | ||
u: { | ||
_id: user._id, | ||
username: user.username, | ||
name: user.name | ||
}, | ||
scope: rid | ||
}); | ||
} | ||
|
||
return true; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Meteor.methods({ | ||
removeRoomLeader(rid, userId) { | ||
check(rid, String); | ||
check(userId, String); | ||
|
||
if (!Meteor.userId()) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
method: 'removeRoomLeader' | ||
}); | ||
} | ||
|
||
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'set-leader', rid)) { | ||
throw new Meteor.Error('error-not-allowed', 'Not allowed', { | ||
method: 'removeRoomLeader' | ||
}); | ||
} | ||
|
||
const user = RocketChat.models.Users.findOneById(userId); | ||
|
||
if (!user || !user.username) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
method: 'removeRoomLeader' | ||
}); | ||
} | ||
|
||
const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, user._id); | ||
|
||
if (!subscription) { | ||
throw new Meteor.Error('error-user-not-in-room', 'User is not in this room', { | ||
method: 'removeRoomLeader' | ||
}); | ||
} | ||
|
||
if (Array.isArray(subscription.roles) === true && subscription.roles.includes('leader') === false) { | ||
throw new Meteor.Error('error-user-already-leader', 'User is not a leader', { | ||
method: 'removeRoomLeader' | ||
}); | ||
} | ||
|
||
RocketChat.models.Subscriptions.removeRoleById(subscription._id, 'leader'); | ||
|
||
const fromUser = RocketChat.models.Users.findOneById(Meteor.userId()); | ||
|
||
RocketChat.models.Messages.createSubscriptionRoleRemovedWithRoomIdAndUser(rid, user, { | ||
u: { | ||
_id: fromUser._id, | ||
username: fromUser.username | ||
}, | ||
role: 'leader' | ||
}); | ||
|
||
if (RocketChat.settings.get('UI_DisplayRoles')) { | ||
RocketChat.Notifications.notifyLogged('roles-change', { | ||
type: 'removed', | ||
_id: 'leader', | ||
u: { | ||
_id: user._id, | ||
username: user.username, | ||
name: user.name | ||
}, | ||
scope: rid | ||
}); | ||
} | ||
|
||
return true; | ||
} | ||
}); |