mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
pad: Pass color and display name in CLIENT_READY
This commit is contained in:
parent
7a0d8cb52e
commit
56cb08f4c5
3 changed files with 22 additions and 12 deletions
|
@ -814,6 +814,7 @@ const handleClientReady = async (socket, message) => {
|
|||
const sessionInfo = sessioninfos[socket.id];
|
||||
// Check if the user has already disconnected.
|
||||
if (sessionInfo == null) return;
|
||||
assert(sessionInfo.author);
|
||||
|
||||
const padIds = await readOnlyManager.getIds(sessionInfo.auth.padID);
|
||||
sessionInfo.padId = padIds.padId;
|
||||
|
@ -823,10 +824,16 @@ const handleClientReady = async (socket, message) => {
|
|||
|
||||
await hooks.aCallAll('clientReady', message); // Deprecated due to awkward context.
|
||||
|
||||
// get all authordata of this new user
|
||||
assert(sessionInfo.author);
|
||||
const {colorId: authorColorId, name: authorName} =
|
||||
await authorManager.getAuthor(sessionInfo.author);
|
||||
let {colorId: authorColorId, name: authorName} = message.userInfo || {};
|
||||
if (authorColorId && !/^#(?:[0-9A-F]{3}){1,2}$/i.test(authorColorId)) {
|
||||
messageLogger.warn(`Ignoring invalid colorId in CLIENT_READY message: ${authorColorId}`);
|
||||
authorColorId = null;
|
||||
}
|
||||
await Promise.all([
|
||||
authorName && authorManager.setAuthorName(sessionInfo.author, authorName),
|
||||
authorColorId && authorManager.setAuthorColorId(sessionInfo.author, authorColorId),
|
||||
]);
|
||||
({colorId: authorColorId, name: authorName} = await authorManager.getAuthor(sessionInfo.author));
|
||||
|
||||
// load the pad-object from the database
|
||||
const pad = await padManager.getPad(sessionInfo.padId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue