{"action":"created","comment":{"url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/comments/77145486","id":77145486,"diff_hunk":"@@ -187,9 +192,101 @@ - (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest\n \t\treturn NO;\n \t}\n \t\n+\tNSString *logUploadPrefix = @\"testers-app://get-log\";\n+\tif ([url hasPrefix:logUploadPrefix]) {\n+\t\t[self uploadLogs:[self extractSenders:url prefix:logUploadPrefix]];\n+\t\treturn NO;\n+\t}\n+\t\n \treturn [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];\n }\n \n+- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {\n+\t@try {\n+\t\tNSError *error;\n+\t\tNSString *jsonString = [[NSString alloc] initWithData:data  encoding:NSUTF8StringEncoding];\n+\t\tNSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];\n+\t\tNSDictionary *responseData = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];\n+\t\tNSString *redirect = [responseData objectForKey:@\"redirect\"];\n+\t\t[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:redirect]]];\n+\t} @catch (NSException * exception) {\n+\t\tNSLog(@\"TestFairy: Exception when parsing response data\");\n+\t}\n+}\n+\n+- (void) uploadLogs:(NSArray *)senders {\n+\tdispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{\n+\t\tNSArray *logs = [TFLogReader logs:senders];\n+\t\tNSMutableString *log = [NSMutableString string];\n+\t\tfor (NSString *item in logs) {\n+\t\t\t[log appendString:item];\n+\t\t\t[log appendString:@\"\\r\\n\"];\n+\t\t}\n+\n+\t\tNSDictionary *data = @{@\"logs\": log};\n+\t\tNSURLRequest *request = [self createRequest:data];\n+\t\t\n+\t\tdispatch_async(dispatch_get_main_queue(), ^{\n+\t\t\t[NSURLConnection connectionWithRequest:request delegate:self];\n+\t\t});\n+\t});\n+}\n+\n+- (NSURLRequest *) createRequest:(NSDictionary *)requestData {\n+\tNSString *url = [NSString stringWithFormat:@\"%@/my/troubleshooting/logs-analysis\", self.startPage];\n+\tNSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];\n+\t[request setTimeoutInterval:30];\n+\t[request setHTTPMethod:@\"POST\"];\n+\t\n+\tNSString *boundary = @\"EZg2YAjpj1YPo2yp\";\n+\tNSMutableData *body = [NSMutableData data];\n+\t\n+\tNSString *contentType = [NSString stringWithFormat:@\"multipart/form-data; boundary=%@\", boundary];\n+\t[request setValue:contentType forHTTPHeaderField: @\"Content-Type\"];\n+\t\n+\t// add params (all params are strings)\n+\tfor (NSString *param in [requestData allKeys]) {\n+\t\t[body appendData:[[NSString stringWithFormat:@\"--%@\\r\\n\", boundary] dataUsingEncoding:NSUTF8StringEncoding]];\n+\t\t[body appendData:[[NSString stringWithFormat:@\"Content-Disposition: form-data; name=\\\"%@\\\"\\r\\n\\r\\n\", param] dataUsingEncoding:NSUTF8StringEncoding]];\n+\t\t\n+\t\tNSObject *value = [requestData objectForKey:param];\n+\t\tif ([value isKindOfClass:[NSData class]]) {\n+\t\t\t// send as binary\n+\t\t\t[body appendData:(NSData *)value];\n+\t\t\t[body appendData:[@\"%@\\r\\n\" dataUsingEncoding:NSUTF8StringEncoding]];\n+\t\t} else {\n+\t\t\t// use string encoding\n+\t\t\t[body appendData:[[NSString stringWithFormat:@\"%@\\r\\n\", value] dataUsingEncoding:NSUTF8StringEncoding]];\n+\t\t}\n+\t}\n+\t\n+\t[body appendData:[[NSString stringWithFormat:@\"--%@--\\r\\n\", boundary] dataUsingEncoding:NSUTF8StringEncoding]];\n+\t\n+\t// setting the body of the post to the reqeust\n+\t[request setHTTPBody:body];\n+\t\n+\treturn request;\n+}\n+\n+- (NSArray *)extractSenders:(NSString *)url prefix:(NSString *)prefix {","path":"src/platforms/ios/TestFairy/Classes/MainViewController.m","position":96,"original_position":96,"commit_id":"96635d7386dd9ac547aaf0e472a74de28dada272","original_commit_id":"96635d7386dd9ac547aaf0e472a74de28dada272","user":{"login":"gmegidish","id":2457607,"avatar_url":"https://avatars.githubusercontent.com/u/2457607?v=3","gravatar_id":"","url":"https://api.github.com/users/gmegidish","html_url":"https://github.com/gmegidish","followers_url":"https://api.github.com/users/gmegidish/followers","following_url":"https://api.github.com/users/gmegidish/following{/other_user}","gists_url":"https://api.github.com/users/gmegidish/gists{/gist_id}","starred_url":"https://api.github.com/users/gmegidish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmegidish/subscriptions","organizations_url":"https://api.github.com/users/gmegidish/orgs","repos_url":"https://api.github.com/users/gmegidish/repos","events_url":"https://api.github.com/users/gmegidish/events{/privacy}","received_events_url":"https://api.github.com/users/gmegidish/received_events","type":"User","site_admin":false},"body":"Why pass prefix and not just the appropriate substring when calling this method?","created_at":"2016-09-01T09:55:13Z","updated_at":"2016-09-01T09:55:13Z","html_url":"https://github.com/testfairy/testers-app-ios/pull/6#discussion_r77145486","pull_request_url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/comments/77145486"},"html":{"href":"https://github.com/testfairy/testers-app-ios/pull/6#discussion_r77145486"},"pull_request":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6","id":80635971,"html_url":"https://github.com/testfairy/testers-app-ios/pull/6","diff_url":"https://github.com/testfairy/testers-app-ios/pull/6.diff","patch_url":"https://github.com/testfairy/testers-app-ios/pull/6.patch","issue_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues/6","number":6,"state":"open","locked":false,"title":"Upload logs","user":{"login":"vijaysharm","id":1824094,"avatar_url":"https://avatars.githubusercontent.com/u/1824094?v=3","gravatar_id":"","url":"https://api.github.com/users/vijaysharm","html_url":"https://github.com/vijaysharm","followers_url":"https://api.github.com/users/vijaysharm/followers","following_url":"https://api.github.com/users/vijaysharm/following{/other_user}","gists_url":"https://api.github.com/users/vijaysharm/gists{/gist_id}","starred_url":"https://api.github.com/users/vijaysharm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vijaysharm/subscriptions","organizations_url":"https://api.github.com/users/vijaysharm/orgs","repos_url":"https://api.github.com/users/vijaysharm/repos","events_url":"https://api.github.com/users/vijaysharm/events{/privacy}","received_events_url":"https://api.github.com/users/vijaysharm/received_events","type":"User","site_admin":false},"body":"@gmegidish Here's the code to upload all the logs. I just want to run the \"url\" used, and the contents of the body by you. ","created_at":"2016-08-09T14:57:08Z","updated_at":"2016-09-01T09:55:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c10bc2beae0d159570d532e8b11690e0a58c1573","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6/commits","review_comments_url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6/comments","review_comment_url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues/6/comments","statuses_url":"https://api.github.com/repos/testfairy/testers-app-ios/statuses/96635d7386dd9ac547aaf0e472a74de28dada272","head":{"label":"testfairy:feat-troubleshooting","ref":"feat-troubleshooting","sha":"96635d7386dd9ac547aaf0e472a74de28dada272","user":{"login":"testfairy","id":6095613,"avatar_url":"https://avatars.githubusercontent.com/u/6095613?v=3","gravatar_id":"","url":"https://api.github.com/users/testfairy","html_url":"https://github.com/testfairy","followers_url":"https://api.github.com/users/testfairy/followers","following_url":"https://api.github.com/users/testfairy/following{/other_user}","gists_url":"https://api.github.com/users/testfairy/gists{/gist_id}","starred_url":"https://api.github.com/users/testfairy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/testfairy/subscriptions","organizations_url":"https://api.github.com/users/testfairy/orgs","repos_url":"https://api.github.com/users/testfairy/repos","events_url":"https://api.github.com/users/testfairy/events{/privacy}","received_events_url":"https://api.github.com/users/testfairy/received_events","type":"Organization","site_admin":false},"repo":{"id":31058134,"name":"testers-app-ios","full_name":"testfairy/testers-app-ios","owner":{"login":"testfairy","id":6095613,"avatar_url":"https://avatars.githubusercontent.com/u/6095613?v=3","gravatar_id":"","url":"https://api.github.com/users/testfairy","html_url":"https://github.com/testfairy","followers_url":"https://api.github.com/users/testfairy/followers","following_url":"https://api.github.com/users/testfairy/following{/other_user}","gists_url":"https://api.github.com/users/testfairy/gists{/gist_id}","starred_url":"https://api.github.com/users/testfairy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/testfairy/subscriptions","organizations_url":"https://api.github.com/users/testfairy/orgs","repos_url":"https://api.github.com/users/testfairy/repos","events_url":"https://api.github.com/users/testfairy/events{/privacy}","received_events_url":"https://api.github.com/users/testfairy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/testfairy/testers-app-ios","description":"","fork":false,"url":"https://api.github.com/repos/testfairy/testers-app-ios","forks_url":"https://api.github.com/repos/testfairy/testers-app-ios/forks","keys_url":"https://api.github.com/repos/testfairy/testers-app-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/testfairy/testers-app-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/testfairy/testers-app-ios/teams","hooks_url":"https://api.github.com/repos/testfairy/testers-app-ios/hooks","issue_events_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues/events{/number}","events_url":"https://api.github.com/repos/testfairy/testers-app-ios/events","assignees_url":"https://api.github.com/repos/testfairy/testers-app-ios/assignees{/user}","branches_url":"https://api.github.com/repos/testfairy/testers-app-ios/branches{/branch}","tags_url":"https://api.github.com/repos/testfairy/testers-app-ios/tags","blobs_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/testfairy/testers-app-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/testfairy/testers-app-ios/languages","stargazers_url":"https://api.github.com/repos/testfairy/testers-app-ios/stargazers","contributors_url":"https://api.github.com/repos/testfairy/testers-app-ios/contributors","subscribers_url":"https://api.github.com/repos/testfairy/testers-app-ios/subscribers","subscription_url":"https://api.github.com/repos/testfairy/testers-app-ios/subscription","commits_url":"https://api.github.com/repos/testfairy/testers-app-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/testfairy/testers-app-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/testfairy/testers-app-ios/contents/{+path}","compare_url":"https://api.github.com/repos/testfairy/testers-app-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/testfairy/testers-app-ios/merges","archive_url":"https://api.github.com/repos/testfairy/testers-app-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/testfairy/testers-app-ios/downloads","issues_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues{/number}","pulls_url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/testfairy/testers-app-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/testfairy/testers-app-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/testfairy/testers-app-ios/labels{/name}","releases_url":"https://api.github.com/repos/testfairy/testers-app-ios/releases{/id}","deployments_url":"https://api.github.com/repos/testfairy/testers-app-ios/deployments","created_at":"2015-02-20T09:25:42Z","updated_at":"2016-06-09T07:08:08Z","pushed_at":"2016-08-25T14:17:18Z","git_url":"git://github.com/testfairy/testers-app-ios.git","ssh_url":"git@github.com:testfairy/testers-app-ios.git","clone_url":"https://github.com/testfairy/testers-app-ios.git","svn_url":"https://github.com/testfairy/testers-app-ios","homepage":null,"size":20560,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"testfairy:master","ref":"master","sha":"ffb13beed2f6ccbab6f1c9c3679059abcd5ef04c","user":{"login":"testfairy","id":6095613,"avatar_url":"https://avatars.githubusercontent.com/u/6095613?v=3","gravatar_id":"","url":"https://api.github.com/users/testfairy","html_url":"https://github.com/testfairy","followers_url":"https://api.github.com/users/testfairy/followers","following_url":"https://api.github.com/users/testfairy/following{/other_user}","gists_url":"https://api.github.com/users/testfairy/gists{/gist_id}","starred_url":"https://api.github.com/users/testfairy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/testfairy/subscriptions","organizations_url":"https://api.github.com/users/testfairy/orgs","repos_url":"https://api.github.com/users/testfairy/repos","events_url":"https://api.github.com/users/testfairy/events{/privacy}","received_events_url":"https://api.github.com/users/testfairy/received_events","type":"Organization","site_admin":false},"repo":{"id":31058134,"name":"testers-app-ios","full_name":"testfairy/testers-app-ios","owner":{"login":"testfairy","id":6095613,"avatar_url":"https://avatars.githubusercontent.com/u/6095613?v=3","gravatar_id":"","url":"https://api.github.com/users/testfairy","html_url":"https://github.com/testfairy","followers_url":"https://api.github.com/users/testfairy/followers","following_url":"https://api.github.com/users/testfairy/following{/other_user}","gists_url":"https://api.github.com/users/testfairy/gists{/gist_id}","starred_url":"https://api.github.com/users/testfairy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/testfairy/subscriptions","organizations_url":"https://api.github.com/users/testfairy/orgs","repos_url":"https://api.github.com/users/testfairy/repos","events_url":"https://api.github.com/users/testfairy/events{/privacy}","received_events_url":"https://api.github.com/users/testfairy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/testfairy/testers-app-ios","description":"","fork":false,"url":"https://api.github.com/repos/testfairy/testers-app-ios","forks_url":"https://api.github.com/repos/testfairy/testers-app-ios/forks","keys_url":"https://api.github.com/repos/testfairy/testers-app-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/testfairy/testers-app-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/testfairy/testers-app-ios/teams","hooks_url":"https://api.github.com/repos/testfairy/testers-app-ios/hooks","issue_events_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues/events{/number}","events_url":"https://api.github.com/repos/testfairy/testers-app-ios/events","assignees_url":"https://api.github.com/repos/testfairy/testers-app-ios/assignees{/user}","branches_url":"https://api.github.com/repos/testfairy/testers-app-ios/branches{/branch}","tags_url":"https://api.github.com/repos/testfairy/testers-app-ios/tags","blobs_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/testfairy/testers-app-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/testfairy/testers-app-ios/languages","stargazers_url":"https://api.github.com/repos/testfairy/testers-app-ios/stargazers","contributors_url":"https://api.github.com/repos/testfairy/testers-app-ios/contributors","subscribers_url":"https://api.github.com/repos/testfairy/testers-app-ios/subscribers","subscription_url":"https://api.github.com/repos/testfairy/testers-app-ios/subscription","commits_url":"https://api.github.com/repos/testfairy/testers-app-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/testfairy/testers-app-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/testfairy/testers-app-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/testfairy/testers-app-ios/contents/{+path}","compare_url":"https://api.github.com/repos/testfairy/testers-app-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/testfairy/testers-app-ios/merges","archive_url":"https://api.github.com/repos/testfairy/testers-app-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/testfairy/testers-app-ios/downloads","issues_url":"https://api.github.com/repos/testfairy/testers-app-ios/issues{/number}","pulls_url":"https://api.github.com/repos/testfairy/testers-app-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/testfairy/testers-app-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/testfairy/testers-app-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/testfairy/testers-app-ios/labels{/name}","releases_url":"https://api.github.com/repos/testfairy/testers-app-ios/releases{/id}","deployments_url":"https://api.github.com/repos/testfairy/testers-app-ios/deployments","created_at":"2015-02-20T09:25:42Z","updated_at":"2016-06-09T07:08:08Z","pushed_at":"2016-08-25T14:17:18Z","git_url":"git://github.com/testfairy/testers-app-ios.git","ssh_url":"git@github.com:testfairy/testers-app-ios.git","clone_url":"https://github.com/testfairy/testers-app-ios.git","svn_url":"https://github.com/testfairy/testers-app-ios","homepage":null,"size":20560,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6"},"html":{"href":"https://github.com/testfairy/testers-app-ios/pull/6"},"issue":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/issues/6"},"comments":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/testfairy/testers-app-ios/statuses/96635d7386dd9ac547aaf0e472a74de28dada272"}}}}
{"actor":{"display_login":"gmegidish"}}