New feature flag with ability to migrate GV1 groups

This commit is contained in:
Scott Nonnenberg 2020-12-01 08:42:35 -08:00 committed by GitHub
parent 089a6fb5a2
commit 2b8ae412e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 608 additions and 189 deletions

View file

@ -2079,33 +2079,42 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const isOutgoing = this.get('type') === 'outgoing';
const numDelivered = this.get('delivered');
// Case 1: If mandatory profile sharing is enabled, and we haven't shared yet, then
if (!conversation) {
return false;
}
// If GroupV1 groups have been disabled, we can't reply.
if (conversation.isGroupV1AndDisabled()) {
return false;
}
// If mandatory profile sharing is enabled, and we haven't shared yet, then
// we can't reply.
if (conversation?.isMissingRequiredProfileSharing()) {
if (conversation.isMissingRequiredProfileSharing()) {
return false;
}
// Case 2: We cannot reply if we have accepted the message request
if (!conversation?.getAccepted()) {
// We cannot reply if we haven't accepted the message request
if (!conversation.getAccepted()) {
return false;
}
// Case 3: We cannot reply if this message is deleted for everyone
// We cannot reply if this message is deleted for everyone
if (this.get('deletedForEveryone')) {
return false;
}
// Case 4: We can reply if this is outgoing and delievered to at least one recipient
// We can reply if this is outgoing and delievered to at least one recipient
if (isOutgoing && numDelivered > 0) {
return true;
}
// Case 5: We can reply if there are no errors
// We can reply if there are no errors
if (!errors || (errors && errors.length === 0)) {
return true;
}
// Case 6: default
// Fail safe.
return false;
}