-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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 #9048 from RocketChat/livechat-do-not-use-users-co…
…llection [BREAK] Decouple livechat visitors from regular users
- Loading branch information
Showing
152 changed files
with
1,628 additions
and
526 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
88 changes: 88 additions & 0 deletions
88
packages/rocketchat-lib/server/functions/loadMessageHistory.js
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,88 @@ | ||
import _ from 'underscore'; | ||
|
||
const hideMessagesOfType = []; | ||
|
||
RocketChat.settings.get(/Message_HideType_.+/, function(key, value) { | ||
const type = key.replace('Message_HideType_', ''); | ||
const types = type === 'mute_unmute' ? ['user-muted', 'user-unmuted'] : [type]; | ||
|
||
return types.forEach((type) => { | ||
const index = hideMessagesOfType.indexOf(type); | ||
|
||
if (value === true && index === -1) { | ||
return hideMessagesOfType.push(type); | ||
} | ||
|
||
if (index > -1) { | ||
return hideMessagesOfType.splice(index, 1); | ||
} | ||
}); | ||
}); | ||
|
||
RocketChat.loadMessageHistory = function loadMessageHistory({ userId, rid, end, limit = 20, ls }) { | ||
const options = { | ||
sort: { | ||
ts: -1 | ||
}, | ||
limit | ||
}; | ||
|
||
if (!RocketChat.settings.get('Message_ShowEditedStatus')) { | ||
options.fields = { | ||
editedAt: 0 | ||
}; | ||
} | ||
|
||
let records; | ||
if (end != null) { | ||
records = RocketChat.models.Messages.findVisibleByRoomIdBeforeTimestampNotContainingTypes(rid, end, hideMessagesOfType, options).fetch(); | ||
} else { | ||
records = RocketChat.models.Messages.findVisibleByRoomIdNotContainingTypes(rid, hideMessagesOfType, options).fetch(); | ||
} | ||
|
||
const UI_Use_Real_Name = RocketChat.settings.get('UI_Use_Real_Name') === true; | ||
|
||
const messages = records.map((message) => { | ||
message.starred = _.findWhere(message.starred, { | ||
_id: userId | ||
}); | ||
if (message.u && message.u._id && UI_Use_Real_Name) { | ||
const user = RocketChat.models.Users.findOneById(message.u._id); | ||
message.u.name = user && user.name; | ||
} | ||
if (message.mentions && message.mentions.length && UI_Use_Real_Name) { | ||
message.mentions.forEach((mention) => { | ||
const user = RocketChat.models.Users.findOneById(mention._id); | ||
mention.name = user && user.name; | ||
}); | ||
} | ||
return message; | ||
}); | ||
|
||
let unreadNotLoaded = 0; | ||
let firstUnread; | ||
|
||
if (ls != null) { | ||
const firstMessage = messages[messages.length - 1]; | ||
|
||
if ((firstMessage != null ? firstMessage.ts : undefined) > ls) { | ||
delete options.limit; | ||
|
||
const unreadMessages = RocketChat.models.Messages.findVisibleByRoomIdBetweenTimestampsNotContainingTypes(rid, ls, firstMessage.ts, hideMessagesOfType, { | ||
limit: 1, | ||
sort: { | ||
ts: 1 | ||
} | ||
}); | ||
|
||
firstUnread = unreadMessages.fetch()[0]; | ||
unreadNotLoaded = unreadMessages.count(); | ||
} | ||
} | ||
|
||
return { | ||
messages, | ||
firstUnread, | ||
unreadNotLoaded | ||
}; | ||
}; |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
1 change: 1 addition & 0 deletions
1
...echat/app/client/lib/LivechatVideoCall.js → ...chat/.app/client/lib/LivechatVideoCall.js
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
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.