Skip to content

Commit

Permalink
Fix for #256 - App crashes when trying to generate a thumbnail from a…
Browse files Browse the repository at this point in the history
…n invalid image format that was uploaded from the web client

Incremented app version
  • Loading branch information
Emanuel Lupu-Marinei authored and Emanuel Lupu-Marinei committed Mar 27, 2017
1 parent afa8942 commit fd95b89
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
Expand Up @@ -81,3 +81,7 @@ extern NSString * const kASDKAPIJSONKeyApplicationID;
// Notification keys
extern NSString * const kADSKAPIUnauthorizedRequestNotification;

// Error doomain
extern NSString * const ASDKNetworkServiceErrorDomain;
extern const NSInteger ASDKNetworkServiceErrorInvalidResponseFormat;

Expand Up @@ -106,3 +106,10 @@
#pragma mark Notification keys

NSString * const kADSKAPIUnauthorizedRequestNotification = @"com.alfresco.activiti.ActivitiSDK.networkService.responseSerializer";


#pragma mark -
#pragma mark Error domain

NSString * const ASDKNetworkServiceErrorDomain = @"ASDKNetworkServiceErrorDomain";
const NSInteger ASDKNetworkServiceErrorInvalidResponseFormat = 1;
Expand Up @@ -278,13 +278,26 @@ - (void)fetchProfileImageWithCompletionBlock:(ASDKProfileImageCompletionBlock)co
// Remove operation reference
[strongSelf.networkOperations removeObject:dataTask];

UIImage *profileImage = (UIImage *)responseObject;
ASDKLogVerbose(@"Profile picture fetched successfully for request: %@.",
[task stateDescriptionForResponse:nil]);

dispatch_async(strongSelf.resultsQueue, ^{
completionBlock(profileImage, nil);
});
UIImage *profileImage = nil;
if ([responseObject isKindOfClass:[UIImage class]]) {
ASDKLogVerbose(@"Profile picture fetched successfully for request: %@.",
[task stateDescriptionForResponse:nil]);
profileImage = (UIImage *)responseObject;

dispatch_async(strongSelf.resultsQueue, ^{
completionBlock(profileImage, nil);
});
} else {
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid image format received", @""),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Image cannot be parsed from response because a different format than expected was received:%@", NSStringFromClass([responseObject class])]};
NSError *imageFormatError = [NSError errorWithDomain:ASDKNetworkServiceErrorDomain
code:ASDKNetworkServiceErrorInvalidResponseFormat
userInfo:userInfo];

dispatch_async(strongSelf.resultsQueue, ^{
completionBlock(nil, imageFormatError);
});
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
__strong typeof(self) strongSelf = weakSelf;

Expand Down
2 changes: 1 addition & 1 deletion AlfrescoActiviti/Info.plist
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>88</string>
<string>89</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
2 changes: 1 addition & 1 deletion AlfrescoActiviti/Resources/Settings.bundle/Root.plist
Expand Up @@ -12,7 +12,7 @@
</dict>
<dict>
<key>DefaultValue</key>
<string>1.1 (88)</string>
<string>1.1 (89)</string>
<key>Key</key>
<string>Prefs_AppVersion</string>
<key>Title</key>
Expand Down

0 comments on commit fd95b89

Please sign in to comment.