Add support for getting chat limit from database (#14392)

* Add support for getting chat limit from database

* fix lint error
This commit is contained in:
Phillip Thelen
2022-12-15 21:38:28 +01:00
committed by GitHub
parent 8a76561259
commit b97da5fe57
2 changed files with 7 additions and 1 deletions

View File

@@ -10,7 +10,12 @@ const questScrolls = shared.content.quests;
// @TODO: Don't use this method when the group can be saved.
export async function getGroupChat (group) {
const maxChatCount = group.hasActiveGroupPlan() ? MAX_SUBBED_GROUP_CHAT_COUNT : MAX_CHAT_COUNT;
let maxChatCount = MAX_CHAT_COUNT;
if (group.chatLimitCount && group.chatLimitCount >= MAX_CHAT_COUNT) {
maxChatCount = group.chatLimitCount;
} else if (group.hasActiveGroupPlan()) {
maxChatCount = MAX_SUBBED_GROUP_CHAT_COUNT;
}
const groupChat = await Chat.find({ groupId: group._id })
.limit(maxChatCount)

View File

@@ -91,6 +91,7 @@ export const schema = new Schema({
},
memberCount: { $type: Number, default: 1 },
challengeCount: { $type: Number, default: 0 },
chatLimitCount: { $type: Number },
balance: { $type: Number, default: 0 },
logo: String,
leaderMessage: String,