|
|
@ -967,7 +967,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
return [self saveMediaAlbumItems:mediaAlbumItems];
|
|
|
|
return [self saveMediaAlbumItems:mediaAlbumItems];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)deleteAction
|
|
|
|
- (void)deleteLocallyAction
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
[self.interaction removeWithTransaction:transaction];
|
|
|
|
[self.interaction removeWithTransaction:transaction];
|
|
|
@ -975,6 +975,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
[LKStorage.shared cancelPendingMessageSendJobIfNeededForMessage:self.interaction.timestamp using:transaction];
|
|
|
|
[LKStorage.shared cancelPendingMessageSendJobIfNeededForMessage:self.interaction.timestamp using:transaction];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)deleteRemotelyAction
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: closefd group and one-on-one chat
|
|
|
|
|
|
|
|
|
|
|
|
if (self.isGroupThread) {
|
|
|
|
if (self.isGroupThread) {
|
|
|
|
TSGroupThread *groupThread = (TSGroupThread *)self.interaction.thread;
|
|
|
|
TSGroupThread *groupThread = (TSGroupThread *)self.interaction.thread;
|
|
|
@ -989,24 +994,19 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
|
|
|
|
|
|
|
|
// Get the open group
|
|
|
|
// Get the open group
|
|
|
|
SNOpenGroupV2 *openGroupV2 = [LKStorage.shared getV2OpenGroupForThreadID:groupThread.uniqueId];
|
|
|
|
SNOpenGroupV2 *openGroupV2 = [LKStorage.shared getV2OpenGroupForThreadID:groupThread.uniqueId];
|
|
|
|
if (openGroup == nil && openGroupV2 == nil) return;
|
|
|
|
if (openGroupV2 == nil) return;
|
|
|
|
|
|
|
|
|
|
|
|
// If it's an incoming message the user must have moderator status
|
|
|
|
// If it's an incoming message the user must have moderator status
|
|
|
|
if (self.interaction.interactionType == OWSInteractionType_IncomingMessage) {
|
|
|
|
if (self.interaction.interactionType == OWSInteractionType_IncomingMessage) {
|
|
|
|
NSString *userPublicKey = [LKStorage.shared getUserPublicKey];
|
|
|
|
NSString *userPublicKey = [LKStorage.shared getUserPublicKey];
|
|
|
|
if (openGroupV2 != nil) {
|
|
|
|
if (![SNOpenGroupAPIV2 isUserModerator:userPublicKey forRoom:openGroupV2.room onServer:openGroupV2.server]) { return; }
|
|
|
|
if (![SNOpenGroupAPIV2 isUserModerator:userPublicKey forRoom:openGroupV2.room onServer:openGroupV2.server]) { return; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Delete the message
|
|
|
|
// Delete the message
|
|
|
|
BOOL wasSentByUser = (interationType == OWSInteractionType_OutgoingMessage);
|
|
|
|
[[SNOpenGroupAPIV2 deleteMessageWithServerID:message.openGroupServerMessageID fromRoom:openGroupV2.room onServer:openGroupV2.server].catch(^(NSError *error) {
|
|
|
|
if (openGroupV2 != nil) {
|
|
|
|
// Roll back
|
|
|
|
[[SNOpenGroupAPIV2 deleteMessageWithServerID:message.openGroupServerMessageID fromRoom:openGroupV2.room onServer:openGroupV2.server].catch(^(NSError *error) {
|
|
|
|
[self.interaction save];
|
|
|
|
// Roll back
|
|
|
|
}) retainUntilComplete];
|
|
|
|
[self.interaction save];
|
|
|
|
|
|
|
|
}) retainUntilComplete];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|