Paul Schifferer avatar Paul Schifferer committed 642d329 Merge

Comments (0)

Files changed (12)

Snapper.xcodeproj/project.pbxproj

 		5B6B48F41687CEFC0032C586 /* SNPACL.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B6B48F21687CEFC0032C586 /* SNPACL.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5B6B48F51687CEFC0032C586 /* SNPACL.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B6B48F31687CEFC0032C586 /* SNPACL.m */; };
 		5B6B48F61687CEFC0032C586 /* SNPACL.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B6B48F31687CEFC0032C586 /* SNPACL.m */; };
+		5B7B5ABB17026B130018D2AB /* SNPBaseMessageOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B7B5AB917026B130018D2AB /* SNPBaseMessageOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		5B7B5ABC17026B130018D2AB /* SNPBaseMessageOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B7B5ABA17026B130018D2AB /* SNPBaseMessageOperation.m */; };
+		5B7B5ABD17026B130018D2AB /* SNPBaseMessageOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B7B5ABA17026B130018D2AB /* SNPBaseMessageOperation.m */; };
+		5B7B5AC017026CB00018D2AB /* SNPBaseMessageOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5B7B5AB917026B130018D2AB /* SNPBaseMessageOperation.h */; };
+		5B7B5AC117026CB00018D2AB /* SNPGetMutedChannelsOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5B90EC2516F185B800A50BCF /* SNPGetMutedChannelsOperation.h */; };
+		5B7B5AC217026CB00018D2AB /* SNPMuteChannelOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5B90EC2C16F185CE00A50BCF /* SNPMuteChannelOperation.h */; };
+		5B7B5AC317026CB00018D2AB /* SNPUnmuteChannelOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5B90EC3116F185DB00A50BCF /* SNPUnmuteChannelOperation.h */; };
 		5B8A333416B791B800BE5A8A /* SNPFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B8A333216B791B800BE5A8A /* SNPFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5B8A333516B791B800BE5A8A /* SNPFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B8A333316B791B800BE5A8A /* SNPFile.m */; };
 		5B8A333616B791B800BE5A8A /* SNPFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B8A333316B791B800BE5A8A /* SNPFile.m */; };
 		5B8A334616B7999C00BE5A8A /* SNPBaseFileOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B8A334416B7999C00BE5A8A /* SNPBaseFileOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5B8A334716B7999C00BE5A8A /* SNPBaseFileOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B8A334516B7999C00BE5A8A /* SNPBaseFileOperation.m */; };
 		5B8A334816B7999C00BE5A8A /* SNPBaseFileOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B8A334516B7999C00BE5A8A /* SNPBaseFileOperation.m */; };
-		5B90EC2716F185B800A50BCF /* SNPGetMutedChannelsOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B90EC2516F185B800A50BCF /* SNPGetMutedChannelsOperation.h */; };
+		5B90EC2716F185B800A50BCF /* SNPGetMutedChannelsOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B90EC2516F185B800A50BCF /* SNPGetMutedChannelsOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5B90EC2816F185B800A50BCF /* SNPGetMutedChannelsOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B90EC2616F185B800A50BCF /* SNPGetMutedChannelsOperation.m */; };
 		5B90EC2916F185B800A50BCF /* SNPGetMutedChannelsOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B90EC2616F185B800A50BCF /* SNPGetMutedChannelsOperation.m */; };
-		5B90EC2E16F185CE00A50BCF /* SNPMuteChannelOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B90EC2C16F185CE00A50BCF /* SNPMuteChannelOperation.h */; };
+		5B90EC2E16F185CE00A50BCF /* SNPMuteChannelOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B90EC2C16F185CE00A50BCF /* SNPMuteChannelOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5B90EC2F16F185CE00A50BCF /* SNPMuteChannelOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B90EC2D16F185CE00A50BCF /* SNPMuteChannelOperation.m */; };
 		5B90EC3016F185CE00A50BCF /* SNPMuteChannelOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B90EC2D16F185CE00A50BCF /* SNPMuteChannelOperation.m */; };
-		5B90EC3316F185DB00A50BCF /* SNPUnmuteChannelOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B90EC3116F185DB00A50BCF /* SNPUnmuteChannelOperation.h */; };
+		5B90EC3316F185DB00A50BCF /* SNPUnmuteChannelOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B90EC3116F185DB00A50BCF /* SNPUnmuteChannelOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5B90EC3416F185DB00A50BCF /* SNPUnmuteChannelOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B90EC3216F185DB00A50BCF /* SNPUnmuteChannelOperation.m */; };
 		5B90EC3516F185DB00A50BCF /* SNPUnmuteChannelOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B90EC3216F185DB00A50BCF /* SNPUnmuteChannelOperation.m */; };
 		5B9BB24A16EB8A00007E833A /* SNPExploreStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B9BB24816EB8A00007E833A /* SNPExploreStream.h */; settings = {ATTRIBUTES = (Public, ); }; };
 			dstPath = include/Snapper;
 			dstSubfolderSpec = 16;
 			files = (
+				5B7B5AC017026CB00018D2AB /* SNPBaseMessageOperation.h in CopyFiles */,
+				5B7B5AC117026CB00018D2AB /* SNPGetMutedChannelsOperation.h in CopyFiles */,
+				5B7B5AC217026CB00018D2AB /* SNPMuteChannelOperation.h in CopyFiles */,
+				5B7B5AC317026CB00018D2AB /* SNPUnmuteChannelOperation.h in CopyFiles */,
 				5B9BB25716EB922E007E833A /* SNPExploreStream.h in CopyFiles */,
 				5B9BB25816EB922E007E833A /* SNPReportPostOperation.h in CopyFiles */,
 				5B9BB25916EB922E007E833A /* SNPGetAllExploreStreamsOperation.h in CopyFiles */,
 		5B6B48EE1687CDF90032C586 /* SNPBaseClientOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SNPBaseClientOperation.m; sourceTree = "<group>"; };
 		5B6B48F21687CEFC0032C586 /* SNPACL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SNPACL.h; sourceTree = "<group>"; };
 		5B6B48F31687CEFC0032C586 /* SNPACL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SNPACL.m; sourceTree = "<group>"; };
+		5B7B5AB917026B130018D2AB /* SNPBaseMessageOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SNPBaseMessageOperation.h; sourceTree = "<group>"; };
+		5B7B5ABA17026B130018D2AB /* SNPBaseMessageOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SNPBaseMessageOperation.m; sourceTree = "<group>"; };
 		5B8A333216B791B800BE5A8A /* SNPFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SNPFile.h; sourceTree = "<group>"; };
 		5B8A333316B791B800BE5A8A /* SNPFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SNPFile.m; sourceTree = "<group>"; };
 		5B8A333916B7980B00BE5A8A /* SNPSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SNPSource.h; sourceTree = "<group>"; };
 				5B2E458E16A36DCD000CCDB6 /* SNPBaseImageUpdateOperation.m */,
 				3C6B5F80168109C8006C63C1 /* SNPBaseUserOperation.h */,
 				3C6B5F81168109C8006C63C1 /* SNPBaseUserOperation.m */,
+				5B7B5AB917026B130018D2AB /* SNPBaseMessageOperation.h */,
+				5B7B5ABA17026B130018D2AB /* SNPBaseMessageOperation.m */,
 				3CDF11E71683B6B70058CBE0 /* Channels */,
 				5B8A333E16B7992900BE5A8A /* Files */,
 				3CDF11EA1683B6CE0058CBE0 /* Filters */,
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				5B90EC2716F185B800A50BCF /* SNPGetMutedChannelsOperation.h in Headers */,
+				5B90EC2E16F185CE00A50BCF /* SNPMuteChannelOperation.h in Headers */,
+				5B90EC3316F185DB00A50BCF /* SNPUnmuteChannelOperation.h in Headers */,
+				5B7B5ABB17026B130018D2AB /* SNPBaseMessageOperation.h in Headers */,
 				5B9BB24A16EB8A00007E833A /* SNPExploreStream.h in Headers */,
 				5B9BB24F16EB8ABA007E833A /* SNPGetAllExploreStreamsOperation.h in Headers */,
 				5B9BB25416EB8C92007E833A /* SNPGetExploreStreamOperation.h in Headers */,
 				5B6B48EF1687CDF90032C586 /* SNPBaseClientOperation.h in Headers */,
 				5B6B48F41687CEFC0032C586 /* SNPACL.h in Headers */,
 				3CDF12A01683C8CE0058CBE0 /* SNPUpdateUserOperation.h in Headers */,
-				5B90EC2716F185B800A50BCF /* SNPGetMutedChannelsOperation.h in Headers */,
-				5B90EC2E16F185CE00A50BCF /* SNPMuteChannelOperation.h in Headers */,
-				5B90EC3316F185DB00A50BCF /* SNPUnmuteChannelOperation.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				5B90EC2816F185B800A50BCF /* SNPGetMutedChannelsOperation.m in Sources */,
 				5B90EC2F16F185CE00A50BCF /* SNPMuteChannelOperation.m in Sources */,
 				5B90EC3416F185DB00A50BCF /* SNPUnmuteChannelOperation.m in Sources */,
+				5B7B5ABC17026B130018D2AB /* SNPBaseMessageOperation.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				5B90EC2916F185B800A50BCF /* SNPGetMutedChannelsOperation.m in Sources */,
 				5B90EC3016F185CE00A50BCF /* SNPMuteChannelOperation.m in Sources */,
 				5B90EC3516F185DB00A50BCF /* SNPUnmuteChannelOperation.m in Sources */,
+				5B7B5ABD17026B130018D2AB /* SNPBaseMessageOperation.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Snapper/Source/Shared/SNPBaseMessageOperation.h

+//
+//  SNPBaseMessageOperation.h
+//  Snapper
+//
+//  Created by Paul Schifferer on 3/26/13.
+//  Copyright (c) 2013 Pilgrimage Software. All rights reserved.
+//
+
+#import "SNPBaseUserOperation.h"
+
+
+@interface SNPBaseMessageOperation : SNPBaseUserOperation
+
+// -- Properties --
+@property (nonatomic, assign) NSUInteger beforeId;
+@property (nonatomic, assign) NSUInteger sinceId;
+@property (nonatomic, assign) NSInteger count;
+@property (nonatomic, assign) BOOL includeMachine;
+@property (nonatomic, assign) BOOL includeMuted;
+@property (nonatomic, assign) BOOL includeDeleted;
+@property (nonatomic, assign) BOOL includeAnnotations;
+@property (nonatomic, assign) BOOL includeMessageAnnotations;
+@property (nonatomic, assign) BOOL includeUserAnnotations;
+
+@end

Snapper/Source/Shared/SNPBaseMessageOperation.m

+//
+//  SNPBaseMessageOperation.m
+//  Snapper
+//
+//  Created by Paul Schifferer on 3/26/13.
+//  Copyright (c) 2013 Pilgrimage Software. All rights reserved.
+//
+
+#import "SNPBaseMessageOperation.h"
+
+
+@implementation SNPBaseMessageOperation
+
+- (void)main {
+
+    NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
+
+    if(self.parameters) {
+        [parameters addEntriesFromDictionary:self.parameters];
+    }
+
+    if(_beforeId) {
+        parameters[@"before_id"] = @(_beforeId);
+    }
+    if(_sinceId) {
+        parameters[@"since_id"] = @(_sinceId);
+    }
+    if(_count) {
+        parameters[@"count"] = @(_count);
+    }
+    if(_includeAnnotations) {
+        parameters[@"include_annotations"] = @(_includeAnnotations);
+    }
+    if(_includeMachine) {
+        parameters[@"include_machine"] = @(_includeMachine);
+    }
+    if(_includeMuted) {
+        parameters[@"include_muted"] = @(_includeMuted);
+    }
+    if(_includeDeleted) {
+        parameters[@"include_deleted"] = @(_includeDeleted);
+    }
+    if(_includeUserAnnotations) {
+        parameters[@"include_user_annotations"] = @(_includeUserAnnotations);
+    }
+
+    if([[parameters allKeys] count]) {
+        self.parameters = parameters;
+    }
+
+    [super main];
+}
+
+@end

Snapper/Source/Shared/SNPBaseStreamOperation.m

         parameters[@"include_reposters"] = @(_includeReposters);
     }
 
-    self.parameters = parameters;
-
-//    self.serializationArrayClass = [SNPPost class];
+    if([[parameters allKeys] count]) {
+        self.parameters = parameters;
+    }
 
     [super main];
 }

Snapper/Source/Shared/SNPChannel.m

 
 #import "SNPChannel.h"
 
+#import "SNPAnnotation.h"
+
 
 @implementation SNPChannel
 
                                                          }];
 }
 
++ (NSValueTransformer*)annotationsTransformer {
+    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSArray* annotationDicts) {
+        NSMutableArray* annotations = [NSMutableArray new];
+
+        for(NSDictionary* annoDict in annotationDicts) {
+            SNPAnnotation* annotation = [[SNPAnnotation alloc] initWithExternalRepresentation:annoDict];
+
+            [annotations addObject:annotation];
+        }
+
+        return [annotations copy];
+    }
+                                                         reverseBlock:^(NSArray* annotations) {
+                                                             NSMutableArray* annoDicts = [NSMutableArray new];
+
+                                                             for(SNPAnnotation* annotation in annotations) {
+                                                                 NSDictionary* annoDict = [annotation externalRepresentation];
+
+                                                                 [annoDicts addObject:annoDict];
+                                                             }
+
+                                                             return [annoDicts copy];
+                                                         }];
+}
+
 @end

Snapper/Source/Shared/SNPGetChannelMessagesOperation.h

 //  Copyright (c) 2012 Pilgrimage Software. All rights reserved.
 //
 
-#import "SNPBaseUserOperation.h"
+#import "SNPBaseMessageOperation.h"
 
 
-@interface SNPGetChannelMessagesOperation : SNPBaseUserOperation
+@interface SNPGetChannelMessagesOperation : SNPBaseMessageOperation
 
 // -- Properties --
 @property (nonatomic, assign) NSUInteger channelId;

Snapper/Source/Shared/SNPMessage.m

 //
 
 #import "SNPMessage.h"
+#import "SNPAnnotation.h"
 
 
 @implementation SNPMessage
                                                          }];
 }
 
++ (NSValueTransformer*)annotationsTransformer {
+    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSArray* annotationDicts) {
+        NSMutableArray* annotations = [NSMutableArray new];
+
+        for(NSDictionary* annoDict in annotationDicts) {
+            SNPAnnotation* annotation = [[SNPAnnotation alloc] initWithExternalRepresentation:annoDict];
+
+            [annotations addObject:annotation];
+        }
+
+        return [annotations copy];
+    }
+                                                         reverseBlock:^(NSArray* annotations) {
+                                                             NSMutableArray* annoDicts = [NSMutableArray new];
+
+                                                             for(SNPAnnotation* annotation in annotations) {
+                                                                 NSDictionary* annoDict = [annotation externalRepresentation];
+
+                                                                 [annoDicts addObject:annoDict];
+                                                             }
+
+                                                             return [annoDicts copy];
+                                                         }];
+}
+
 @end

Snapper/Source/Shared/SNPPost.m

 #import "SNPHashtag.h"
 #import "SNPMention.h"
 #import "SNPLink.h"
+#import "SNPAnnotation.h"
 
 
 @implementation SNPPost
                                                          }];
 }
 
++ (NSValueTransformer*)annotationsTransformer {
+    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSArray* annotationDicts) {
+        NSMutableArray* annotations = [NSMutableArray new];
+
+        for(NSDictionary* annoDict in annotationDicts) {
+            SNPAnnotation* annotation = [[SNPAnnotation alloc] initWithExternalRepresentation:annoDict];
+
+            [annotations addObject:annotation];
+        }
+
+        return [annotations copy];
+    }
+                                                         reverseBlock:^(NSArray* annotations) {
+                                                             NSMutableArray* annoDicts = [NSMutableArray new];
+
+                                                             for(SNPAnnotation* annotation in annotations) {
+                                                                 NSDictionary* annoDict = [annotation externalRepresentation];
+
+                                                                 [annoDicts addObject:annoDict];
+                                                             }
+
+                                                             return [annoDicts copy];
+                                                         }];
+}
+
 @end

Snapper/Source/Shared/SNPUser.m

 //
 
 #import "SNPUser.h"
+#import "SNPAnnotation.h"
 
 
 @implementation SNPUser
                                                          }];
 }
 
++ (NSValueTransformer*)annotationsTransformer {
+    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSArray* annotationDicts) {
+        NSMutableArray* annotations = [NSMutableArray new];
+
+        for(NSDictionary* annoDict in annotationDicts) {
+            SNPAnnotation* annotation = [[SNPAnnotation alloc] initWithExternalRepresentation:annoDict];
+
+            [annotations addObject:annotation];
+        }
+
+        return [annotations copy];
+    }
+                                                         reverseBlock:^(NSArray* annotations) {
+                                                             NSMutableArray* annoDicts = [NSMutableArray new];
+
+                                                             for(SNPAnnotation* annotation in annotations) {
+                                                                 NSDictionary* annoDict = [annotation externalRepresentation];
+
+                                                                 [annoDicts addObject:annoDict];
+                                                             }
+                                                             
+                                                             return [annoDicts copy];
+                                                         }];
+}
+
 @end

Snapper/Source/Shared/Snapper.h

 #import <Snapper/SNPBaseStreamOperation.h>
 #import <Snapper/SNPBaseImageFetchOperation.h>
 #import <Snapper/SNPBaseImageUpdateOperation.h>
+#import <Snapper/SNPBaseMessageOperation.h>
 #import <Snapper/SNPBaseUserOperation.h>
 #import <Snapper/SNPCreateChannelOperation.h>
 #import <Snapper/SNPCreateFileOperation.h>

SnapperTests/Resources/post.json

 {
-    "annotations": [],
+    "annotations": [{
+                    "type": "com.pilgrimagesoftware.snapper",
+                    "value": {
+                    "key1": "value1",
+                    "key2": "value2"
+                    }
+                    }],
     "canonical_url": "https://alpha.app.net/pilgrim/post/2165974",
     "created_at": "2012-12-24T04:15:19Z",
     "entities": {

SnapperTests/Source/ModelTests.m

     STAssertNotNil(post.canonicalURL, @"Post 'canonicalURL' property should not be nil");
     STAssertNotNil(post.user, @"Post 'user' property should not be nil");
     STAssertTrue([post.mentions count] == 1, @"Post 'mentions' property should contain 1 item, actually has %d", [post.mentions count]);
+    STAssertTrue([post.annotations count] == 1, @"Post 'annotations' property should contain 1 item, actually has %d", [post.annotations count]);
+
+    SNPAnnotation* annotation = post.annotations[0];
+    STAssertNotNil(annotation, @"Annotation at index 0 should not be nil");
+    STAssertTrue([annotation.type isEqualToString:@"com.pilgrimagesoftware.snapper"], @"Annotation 'type' property should be 'com.pilgrimagesoftware.snapper', is actually %@", annotation.type);
+    NSString* value1 = annotation.value[@"key1"];
+    STAssertNotNil(value1, @"'key1' from annotation should not be nil");
+    STAssertTrue([value1 isEqualToString:@"value1"], @"'key1' value from annotation should be 'value1', is actually %@", value1);
 }
 
 - (void)testRepostFromJSON {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.