Merge branch 'develop' into Yutsuten/party-chat-translations
This commit is contained in:
@@ -10,23 +10,26 @@ const defaultSchema = () => ({
|
||||
info: {type: mongoose.Schema.Types.Mixed},
|
||||
|
||||
// sender properties
|
||||
user: String, // profile name
|
||||
contributor: {type: mongoose.Schema.Types.Mixed},
|
||||
backer: {type: mongoose.Schema.Types.Mixed},
|
||||
user: String, // profile name (unfortunately)
|
||||
username: String,
|
||||
contributor: {$type: mongoose.Schema.Types.Mixed},
|
||||
backer: {$type: mongoose.Schema.Types.Mixed},
|
||||
uuid: String, // sender uuid
|
||||
userStyles: {type: mongoose.Schema.Types.Mixed},
|
||||
userStyles: {$type: mongoose.Schema.Types.Mixed},
|
||||
|
||||
flags: {type: mongoose.Schema.Types.Mixed, default: {}},
|
||||
flagCount: {type: Number, default: 0},
|
||||
likes: {type: mongoose.Schema.Types.Mixed},
|
||||
_meta: {type: mongoose.Schema.Types.Mixed},
|
||||
flags: {$type: mongoose.Schema.Types.Mixed, default: {}},
|
||||
flagCount: {$type: Number, default: 0},
|
||||
likes: {$type: mongoose.Schema.Types.Mixed},
|
||||
client: String,
|
||||
_meta: {$type: mongoose.Schema.Types.Mixed},
|
||||
});
|
||||
|
||||
const chatSchema = new mongoose.Schema({
|
||||
...defaultSchema(),
|
||||
groupId: {type: String, ref: 'Group'},
|
||||
groupId: {$type: String, ref: 'Group'},
|
||||
}, {
|
||||
minimize: false, // Allow for empty flags to be saved
|
||||
typeKey: '$type', // So that we can use fields named `type`
|
||||
});
|
||||
|
||||
chatSchema.plugin(baseModel, {
|
||||
@@ -34,14 +37,15 @@ chatSchema.plugin(baseModel, {
|
||||
});
|
||||
|
||||
const inboxSchema = new mongoose.Schema({
|
||||
sent: {type: Boolean, default: false}, // if the owner sent this message
|
||||
sent: {$type: Boolean, default: false}, // if the owner sent this message
|
||||
// the uuid of the user where the message is stored,
|
||||
// we store two copies of each inbox messages:
|
||||
// one for the sender and one for the receiver
|
||||
ownerId: {type: String, ref: 'User'},
|
||||
ownerId: {$type: String, ref: 'User'},
|
||||
...defaultSchema(),
|
||||
}, {
|
||||
minimize: false, // Allow for empty flags to be saved
|
||||
typeKey: '$type', // So that we can use fields named `type`
|
||||
});
|
||||
|
||||
inboxSchema.plugin(baseModel, {
|
||||
@@ -98,7 +102,7 @@ export function setUserStyles (newMessage, user) {
|
||||
newMessage.markModified('userStyles');
|
||||
}
|
||||
|
||||
export function messageDefaults (msg, user, info = {}) {
|
||||
export function messageDefaults (msg, user, client, info = {}) {
|
||||
const id = uuid();
|
||||
const message = {
|
||||
id,
|
||||
@@ -109,6 +113,7 @@ export function messageDefaults (msg, user, info = {}) {
|
||||
likes: {},
|
||||
flags: {},
|
||||
flagCount: 0,
|
||||
client,
|
||||
};
|
||||
|
||||
if (user) {
|
||||
@@ -117,6 +122,7 @@ export function messageDefaults (msg, user, info = {}) {
|
||||
contributor: user.contributor && user.contributor.toObject(),
|
||||
backer: user.backer && user.backer.toObject(),
|
||||
user: user.profile.name,
|
||||
username: user.flags && user.flags.verifiedUsername && user.auth && user.auth.local && user.auth.local.username,
|
||||
});
|
||||
} else {
|
||||
message.uuid = 'system';
|
||||
|
||||
Reference in New Issue
Block a user