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

@ -632,6 +632,13 @@ export class ConversationModel extends window.Backbone.Model<
window.Signal.Data.updateConversation(this.attributes);
}
isGroupV1AndDisabled(): boolean {
return (
this.isGroupV1() &&
window.Signal.RemoteConfig.isEnabled('desktop.disableGV1')
);
}
isBlocked(): boolean {
const uuid = this.get('uuid');
if (uuid) {
@ -1181,6 +1188,7 @@ export class ConversationModel extends window.Backbone.Model<
isArchived: this.get('isArchived')!,
isBlocked: this.isBlocked(),
isMe: this.isMe(),
isGroupV1AndDisabled: this.isGroupV1AndDisabled(),
isPinned: this.get('isPinned'),
isMissingMandatoryProfileSharing: this.isMissingRequiredProfileSharing(),
isVerified: this.isVerified(),
@ -4063,6 +4071,10 @@ export class ConversationModel extends window.Backbone.Model<
return true;
}
if (this.isGroupV1AndDisabled()) {
return false;
}
if (!this.isGroupV2()) {
return true;
}

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;
}