mirror of https://github.com/oxen-io/session-ios
Auto-rejoin groups by emitting and responding to “request group info” messages.
// FREEBIEpull/1/head
parent
311206918f
commit
315775ff23
@ -0,0 +1,17 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSOutgoingSyncMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSSyncGroupsRequestMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithThread:(nullable TSThread *)thread groupId:(NSData *)groupId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSSyncGroupsRequestMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSSyncGroupsRequestMessage ()
|
||||
|
||||
@property (nonatomic) NSData *groupId;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSSyncGroupsRequestMessage
|
||||
|
||||
- (instancetype)initWithThread:(nullable TSThread *)thread groupId:(NSData *)groupId
|
||||
{
|
||||
self = [super initWithTimestamp:[NSDate ows_millisecondTimeStamp] inThread:thread];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
OWSAssert(groupId.length > 0);
|
||||
_groupId = groupId;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
// override superclass with no-op.
|
||||
//
|
||||
// There's no need to save this message, since it's not displayed to the user.
|
||||
}
|
||||
|
||||
- (BOOL)shouldSyncTranscript
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isLegacyMessage
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder
|
||||
{
|
||||
OWSSignalServiceProtosGroupContextBuilder *groupContextBuilder = [OWSSignalServiceProtosGroupContextBuilder new];
|
||||
[groupContextBuilder setType:OWSSignalServiceProtosGroupContextTypeRequestInfo];
|
||||
[groupContextBuilder setId:self.groupId];
|
||||
|
||||
OWSSignalServiceProtosDataMessageBuilder *builder = [OWSSignalServiceProtosDataMessageBuilder new];
|
||||
[builder setGroupBuilder:groupContextBuilder];
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
- (NSData *)buildPlainTextData
|
||||
{
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
|
||||
[contentBuilder setDataMessageBuilder:[self dataMessageBuilder]];
|
||||
|
||||
return [[contentBuilder build] data];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Loading…
Reference in New Issue