mirror of https://github.com/oxen-io/session-ios
Clean
parent
0f0eba9325
commit
7762418ac1
@ -1,28 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface LKGroupUtil : NSObject
|
||||
|
||||
+(NSString *)getEncodedPublichChatGroupId:(NSString *)groupId;
|
||||
+(NSData *)getEncodedPublichChatGroupIdAsData:(NSString *)groupId;
|
||||
|
||||
+(NSString *)getEncodedRssFeedGroupId:(NSString *)groupId;
|
||||
+(NSData *)getEncodedRssFeedGroupIdAsData:(NSString *)groupId;
|
||||
|
||||
+(NSString *)getEncodedSignalGroupId:(NSString *)groupId;
|
||||
+(NSData *)getEncodedSignalGroupIdAsData:(NSString *)groupId;
|
||||
|
||||
+(NSString *)getEncodedMmsGroupId:(NSString *)groupId;
|
||||
+(NSData *)getEncodedMmsGroupIdAsData:(NSString *)groupId;
|
||||
|
||||
+(NSString *)getEncodedGroupId:(NSData *)groupId;
|
||||
|
||||
+(NSString *)getDecodedGroupId:(NSData *)groupId;
|
||||
+(NSData *)getDecodedGroupIdAsData:(NSData *)groupId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -1,80 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LKGroupUtil.h"
|
||||
|
||||
@implementation LKGroupUtil
|
||||
|
||||
#define SignalGroupPrefix @"__textsecure_group__!"
|
||||
#define MmsGroupPrefix @"__signal_mms_group__!"
|
||||
#define PublicChatGroupPrefix @"__loki_public_chat_group__!"
|
||||
#define RssFeedGroupPrefix @"__loki_rss_feed_group__!"
|
||||
|
||||
+(NSString *)getEncodedPublichChatGroupId:(NSString *)groupId
|
||||
{
|
||||
return [PublicChatGroupPrefix stringByAppendingString:groupId];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedPublichChatGroupIdAsData:(NSString *)groupId
|
||||
{
|
||||
return [[PublicChatGroupPrefix stringByAppendingString:groupId] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedRssFeedGroupId:(NSString *)groupId
|
||||
{
|
||||
return [RssFeedGroupPrefix stringByAppendingString:groupId];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedRssFeedGroupIdAsData:(NSString *)groupId
|
||||
{
|
||||
return [[RssFeedGroupPrefix stringByAppendingString:groupId] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedSignalGroupId:(NSString *)groupId
|
||||
{
|
||||
return [SignalGroupPrefix stringByAppendingString:groupId];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedSignalGroupIdAsData:(NSString *)groupId
|
||||
{
|
||||
return [[SignalGroupPrefix stringByAppendingString:groupId] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedMmsGroupId:(NSString *)groupId
|
||||
{
|
||||
return [MmsGroupPrefix stringByAppendingString:groupId];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedMmsGroupIdAsData:(NSString *)groupId
|
||||
{
|
||||
return [[MmsGroupPrefix stringByAppendingString:groupId] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedGroupId: (NSData *)groupId
|
||||
{
|
||||
return [[NSString alloc]initWithData:groupId encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getDecodedGroupId:(NSData *)groupId
|
||||
{
|
||||
OWSAssertDebug(groupId.length > 0);
|
||||
NSString *encodedGroupId = [[NSString alloc]initWithData:groupId encoding:NSUTF8StringEncoding];
|
||||
if ([encodedGroupId componentsSeparatedByString:@"1"].count > 1) {
|
||||
return [encodedGroupId componentsSeparatedByString:@"!"][1];
|
||||
}
|
||||
return [encodedGroupId componentsSeparatedByString:@"!"][0];
|
||||
}
|
||||
|
||||
+(NSData *)getDecodedGroupIdAsData:(NSData *)groupId
|
||||
{
|
||||
OWSAssertDebug(groupId.length > 0);
|
||||
NSString *encodedGroupId = [[NSString alloc]initWithData:groupId encoding:NSUTF8StringEncoding];
|
||||
NSString *decodedGroupId = [encodedGroupId componentsSeparatedByString:@"!"][0];
|
||||
if ([encodedGroupId componentsSeparatedByString:@"!"].count > 1) {
|
||||
decodedGroupId =[encodedGroupId componentsSeparatedByString:@"!"][1];
|
||||
}
|
||||
return [decodedGroupId dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
@end
|
@ -0,0 +1,24 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface LKGroupUtilities : NSObject
|
||||
|
||||
+(NSString *)getEncodedOpenGroupID:(NSString *)groupID;
|
||||
+(NSData *)getEncodedOpenGroupIDAsData:(NSString *)groupID;
|
||||
|
||||
+(NSString *)getEncodedRSSFeedID:(NSString *)groupID;
|
||||
+(NSData *)getEncodedRSSFeedIDAsData:(NSString *)groupID;
|
||||
|
||||
+(NSString *)getEncodedClosedGroupID:(NSString *)groupID;
|
||||
+(NSData *)getEncodedClosedGroupIDAsData:(NSString *)groupID;
|
||||
|
||||
+(NSString *)getEncodedMMSGroupID:(NSString *)groupID;
|
||||
+(NSData *)getEncodedMMSGroupIDAsData:(NSString *)groupID;
|
||||
|
||||
+(NSString *)getEncodedGroupID:(NSData *)groupID;
|
||||
|
||||
+(NSString *)getDecodedGroupID:(NSData *)groupID;
|
||||
+(NSData *)getDecodedGroupIDAsData:(NSData *)groupID;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,76 @@
|
||||
#import "LKGroupUtilities.h"
|
||||
|
||||
@implementation LKGroupUtilities
|
||||
|
||||
#define ClosedGroupPrefix @"__textsecure_group__!" // a.k.a. private group chat
|
||||
#define MMSGroupPrefix @"__signal_mms_group__!"
|
||||
#define OpenGroupPrefix @"__loki_public_chat_group__!" // a.k.a. public group chat
|
||||
#define RSSFeedPrefix @"__loki_rss_feed_group__!"
|
||||
|
||||
+(NSString *)getEncodedOpenGroupID:(NSString *)groupID
|
||||
{
|
||||
return [OpenGroupPrefix stringByAppendingString:groupID];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedOpenGroupIDAsData:(NSString *)groupID
|
||||
{
|
||||
return [[OpenGroupPrefix stringByAppendingString:groupID] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedRSSFeedID:(NSString *)groupID
|
||||
{
|
||||
return [RSSFeedPrefix stringByAppendingString:groupID];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedRSSFeedIDAsData:(NSString *)groupID
|
||||
{
|
||||
return [[RSSFeedPrefix stringByAppendingString:groupID] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedClosedGroupID:(NSString *)groupID
|
||||
{
|
||||
return [ClosedGroupPrefix stringByAppendingString:groupID];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedClosedGroupIDAsData:(NSString *)groupID
|
||||
{
|
||||
return [[ClosedGroupPrefix stringByAppendingString:groupID] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedMMSGroupID:(NSString *)groupID
|
||||
{
|
||||
return [MMSGroupPrefix stringByAppendingString:groupID];
|
||||
}
|
||||
|
||||
+(NSData *)getEncodedMMSGroupIDAsData:(NSString *)groupID
|
||||
{
|
||||
return [[MMSGroupPrefix stringByAppendingString:groupID] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getEncodedGroupID: (NSData *)groupID
|
||||
{
|
||||
return [[NSString alloc]initWithData:groupID encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+(NSString *)getDecodedGroupID:(NSData *)groupID
|
||||
{
|
||||
OWSAssertDebug(groupID.length > 0);
|
||||
NSString *encodedGroupID = [[NSString alloc] initWithData:groupID encoding:NSUTF8StringEncoding];
|
||||
if ([encodedGroupID componentsSeparatedByString:@"1"].count > 1) {
|
||||
return [encodedGroupID componentsSeparatedByString:@"!"][1];
|
||||
}
|
||||
return [encodedGroupID componentsSeparatedByString:@"!"][0];
|
||||
}
|
||||
|
||||
+(NSData *)getDecodedGroupIDAsData:(NSData *)groupID
|
||||
{
|
||||
OWSAssertDebug(groupID.length > 0);
|
||||
NSString *encodedGroupID = [[NSString alloc]initWithData:groupID encoding:NSUTF8StringEncoding];
|
||||
NSString *decodedGroupID = [encodedGroupID componentsSeparatedByString:@"!"][0];
|
||||
if ([encodedGroupID componentsSeparatedByString:@"!"].count > 1) {
|
||||
decodedGroupID = [encodedGroupID componentsSeparatedByString:@"!"][1];
|
||||
}
|
||||
return [decodedGroupID dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue