Respond to CR.
This commit is contained in:
parent
5bad03f96d
commit
5aa490a1fb
@ -597,83 +597,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||
failure:failure];
|
||||
}
|
||||
|
||||
- (nullable NSArray<SignalServiceAddress *> *)unsentRecipientsForMessage:(TSOutgoingMessage *)message
|
||||
thread:(TSThread *)thread
|
||||
error:(NSError **)errorHandle
|
||||
{
|
||||
OWSAssertDebug(!NSThread.isMainThread);
|
||||
OWSAssertDebug(message);
|
||||
OWSAssertDebug(thread);
|
||||
OWSAssertDebug(errorHandle);
|
||||
|
||||
NSMutableSet<SignalServiceAddress *> *recipientAddresses = [NSMutableSet new];
|
||||
if ([message isKindOfClass:[OWSOutgoingSyncMessage class]]) {
|
||||
[recipientAddresses addObject:self.tsAccountManager.localAddress];
|
||||
} else if (thread.isGroupThread) {
|
||||
TSGroupThread *groupThread = (TSGroupThread *)thread;
|
||||
|
||||
// Send to the intersection of:
|
||||
//
|
||||
// * "sending" recipients of the message.
|
||||
// * members of the group.
|
||||
//
|
||||
// I.e. try to send a message IFF:
|
||||
//
|
||||
// * The recipient was in the group when the message was first tried to be sent.
|
||||
// * The recipient is still in the group.
|
||||
// * The recipient is in the "sending" state.
|
||||
|
||||
[recipientAddresses addObjectsFromArray:message.sendingRecipientAddresses];
|
||||
|
||||
// Only send to members in the latest known group member list...
|
||||
NSMutableSet<SignalServiceAddress *> *currentThreadRecipients = [NSMutableSet new];
|
||||
[currentThreadRecipients addObjectsFromArray:groupThread.groupModel.groupMembers];
|
||||
if ([GroupManager shouldMessageHaveAdditionalRecipients:message groupThread:groupThread]) {
|
||||
// ...or latest known list of "additional recipients".
|
||||
NSSet<SignalServiceAddress *> *additionalRecipients = groupThread.groupModel.groupMembership.pendingMembers;
|
||||
[currentThreadRecipients unionSet:additionalRecipients];
|
||||
}
|
||||
[recipientAddresses intersectSet:currentThreadRecipients];
|
||||
|
||||
if ([recipientAddresses containsObject:self.tsAccountManager.localAddress]) {
|
||||
OWSFailDebug(@"Message send recipients should not include self.");
|
||||
}
|
||||
} else if ([thread isKindOfClass:[TSContactThread class]]) {
|
||||
TSContactThread *contactThread = (TSContactThread *)thread;
|
||||
SignalServiceAddress *recipientAddress = contactThread.contactAddress;
|
||||
|
||||
// Treat 1:1 sends to blocked contacts as failures.
|
||||
// If we block a user, don't send 1:1 messages to them. The UI
|
||||
// should prevent this from occurring, but in some edge cases
|
||||
// you might, for example, have a pending outgoing message when
|
||||
// you block them.
|
||||
OWSAssertDebug(recipientAddress);
|
||||
if ([self.blockingManager isAddressBlocked:recipientAddress]) {
|
||||
OWSLogInfo(@"skipping 1:1 send to blocked contact: %@", recipientAddress);
|
||||
NSError *error = OWSErrorMakeMessageSendFailedDueToBlockListError();
|
||||
[error setIsRetryable:NO];
|
||||
*errorHandle = error;
|
||||
return nil;
|
||||
}
|
||||
|
||||
[recipientAddresses addObject:recipientAddress];
|
||||
|
||||
if ([recipientAddresses containsObject:self.tsAccountManager.localAddress]) {
|
||||
OWSFailDebug(@"Message send recipients should not include self.");
|
||||
}
|
||||
} else {
|
||||
// Neither a group nor contact thread? This should never happen.
|
||||
OWSFailDebug(@"Unknown message type: %@", [message class]);
|
||||
NSError *error = OWSErrorMakeFailedToSendOutgoingMessageError();
|
||||
[error setIsRetryable:NO];
|
||||
*errorHandle = error;
|
||||
return nil;
|
||||
}
|
||||
|
||||
[recipientAddresses minusSet:self.blockingManager.blockedAddresses];
|
||||
return recipientAddresses.allObjects;
|
||||
}
|
||||
|
||||
- (NSArray<SignalRecipient *> *)recipientsForAddresses:(NSArray<SignalServiceAddress *> *)addresses
|
||||
{
|
||||
OWSAssertDebug(!NSThread.isMainThread);
|
||||
@ -827,7 +750,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||
TSContactThread *contactThread = (TSContactThread *)thread;
|
||||
// In the "self-send" aka "Note to Self" special case, we only
|
||||
// need to send a sync message with a delivery receipt.
|
||||
if (contactThread && contactThread.contactAddress.isLocalAddress && !message.isSyncMessage) {
|
||||
if (contactThread.contactAddress.isLocalAddress && !message.isSyncMessage) {
|
||||
// Send to self.
|
||||
OWSAssertDebug(sendInfo.recipients.count == 1);
|
||||
// Don't mark self-sent messages as read (or sent) until the sync transcript is sent.
|
||||
|
||||
@ -646,7 +646,7 @@ extension MessageSending {
|
||||
} else if let contactThread = thread as? TSContactThread {
|
||||
let contactAddress = contactThread.contactAddress
|
||||
if contactAddress.isLocalAddress {
|
||||
owsFailDebug("Message send recipients should not include self.")
|
||||
return [contactAddress]
|
||||
}
|
||||
|
||||
// Treat 1:1 sends to blocked contacts as failures.
|
||||
|
||||
@ -97,16 +97,4 @@ public class TypingIndicatorMessage: TSOutgoingMessage {
|
||||
public override var debugDescription: String {
|
||||
return "typingIndicatorMessage"
|
||||
}
|
||||
|
||||
// MARK:
|
||||
|
||||
@objc(stringForTypingIndicatorAction:)
|
||||
public class func string(forTypingIndicatorAction action: TypingIndicatorAction) -> String {
|
||||
switch action {
|
||||
case .started:
|
||||
return "started"
|
||||
case .stopped:
|
||||
return "stopped"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,16 +29,18 @@ public enum UnidentifiedAccessMode: Int {
|
||||
case unrestricted
|
||||
}
|
||||
|
||||
private func string(forUnidentifiedAccessMode mode: UnidentifiedAccessMode) -> String {
|
||||
switch mode {
|
||||
case .unknown:
|
||||
return "unknown"
|
||||
case .enabled:
|
||||
return "enabled"
|
||||
case .disabled:
|
||||
return "disabled"
|
||||
case .unrestricted:
|
||||
return "unrestricted"
|
||||
extension UnidentifiedAccessMode: CustomStringConvertible {
|
||||
public var description: String {
|
||||
switch self {
|
||||
case .unknown:
|
||||
return "unknown"
|
||||
case .enabled:
|
||||
return "enabled"
|
||||
case .disabled:
|
||||
return "disabled"
|
||||
case .unrestricted:
|
||||
return "unrestricted"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,8 +343,9 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
|
||||
@objc
|
||||
public func setUnidentifiedAccessMode(_ mode: UnidentifiedAccessMode, address: SignalServiceAddress) {
|
||||
if address.isLocalAddress {
|
||||
Logger.info("Setting local UD access mode: \(string(forUnidentifiedAccessMode: mode))")
|
||||
Logger.info("Setting local UD access mode: \(mode)")
|
||||
}
|
||||
|
||||
// Update cache immediately.
|
||||
var didChange = false
|
||||
self.unfairLock.withLock {
|
||||
|
||||
@ -354,7 +354,7 @@ public class TypingIndicatorsImpl: NSObject, TypingIndicators {
|
||||
}
|
||||
|
||||
private func sendTypingMessageIfNecessary(forThread thread: TSThread, action: TypingIndicatorAction) {
|
||||
Logger.verbose("\(TypingIndicatorMessage.string(forTypingIndicatorAction: action))")
|
||||
Logger.verbose("\(action)")
|
||||
|
||||
guard let delegate = delegate else {
|
||||
owsFailDebug("Missing delegate.")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user