Fix debuglogs.org integration

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 913cdad74a
commit 39b87b702b

@ -28,10 +28,13 @@ def execute_command(command):
print e.output print e.output
sys.exit(1) sys.exit(1)
def add_field(curl_command, form_key, form_value):
curl_command.append('-F')
curl_command.append("%s=%s" % (form_key, form_value))
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Precommit cleanup script.') parser = argparse.ArgumentParser(description='Precommit cleanup script.')
parser.add_argument('--file', help='used for starting a new version.') parser.add_argument('--file', required=True, help='used for starting a new version.')
args = parser.parse_args() args = parser.parse_args()
@ -41,24 +44,30 @@ if __name__ == '__main__':
upload_url = params['url'] upload_url = params['url']
upload_fields = params['fields'] upload_fields = params['fields']
upload_key = upload_fields['key']
upload_key = upload_fields.pop('key')
upload_key = upload_key + os.path.splitext(args.file)[1] upload_key = upload_key + os.path.splitext(args.file)[1]
upload_fields['key'] = upload_key
download_url = 'https://debuglogs.org/' + upload_key download_url = 'https://debuglogs.org/' + upload_key
print 'download_url:', download_url print 'download_url:', download_url
curl_command = ['curl', '-v', '-i', '-X', 'POST'] curl_command = ['curl', '-v', '-i', '-X', 'POST']
# key must appear before other fields
add_field(curl_command, 'key', upload_key)
for field_name in upload_fields: for field_name in upload_fields:
field_value = upload_fields[field_name] add_field(curl_command, field_name, upload_fields[field_name])
curl_command.append('-F')
curl_command.append("'%s=%s'" % (field_name, field_value, )) add_field(curl_command, "content-type", "application/octet-stream")
curl_command.append('-F') curl_command.append('-F')
curl_command.append("'file=@%s'" % (args.file,)) curl_command.append("file=@%s" % (args.file,))
curl_command.append(upload_url) curl_command.append(upload_url)
# execute_command(curl_command)
print ' '.join(curl_command) print ' '.join(curl_command)
print 'Running...'
execute_command(curl_command)
print 'download_url:', download_url print 'download_url:', download_url

@ -12,6 +12,7 @@
#import <SignalMessaging/DebugLogger.h> #import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h> #import <SignalMessaging/Environment.h>
#import <SignalServiceKit/AppContext.h> #import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/MimeTypeUtil.h>
#import <SignalServiceKit/TSAccountManager.h> #import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/TSContactThread.h> #import <SignalServiceKit/TSContactThread.h>
#import <SignalServiceKit/TSStorageManager.h> #import <SignalServiceKit/TSStorageManager.h>
@ -150,6 +151,9 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
NSString *fieldValue = fields[fieldName]; NSString *fieldValue = fields[fieldName];
[formData appendPartWithFormData:[fieldValue dataUsingEncoding:NSUTF8StringEncoding] name:fieldName]; [formData appendPartWithFormData:[fieldValue dataUsingEncoding:NSUTF8StringEncoding] name:fieldName];
} }
[formData appendPartWithFormData:[weakSelf.mimeType dataUsingEncoding:NSUTF8StringEncoding]
name:@"content-type"];
NSError *error; NSError *error;
BOOL success = [formData appendPartWithFileURL:weakSelf.fileUrl BOOL success = [formData appendPartWithFileURL:weakSelf.fileUrl
name:@"file" name:@"file"
@ -168,7 +172,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
[self succeedWithUrl:[NSURL URLWithString:urlString]]; [self succeedWithUrl:[NSURL URLWithString:urlString]];
} }
failure:^(NSURLSessionDataTask *_Nullable task, NSError *error) { failure:^(NSURLSessionDataTask *_Nullable task, NSError *error) {
DDLogError(@"%@ failed: %@", weakSelf.logTag, uploadUrl); DDLogError(@"%@ upload: %@ failed with error: %@", weakSelf.logTag, uploadUrl, error);
[weakSelf failWithError:error]; [weakSelf failWithError:error];
}]; }];
} }
@ -427,7 +431,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
__weak Pastelog *weakSelf = self; __weak Pastelog *weakSelf = self;
self.currentUploader = [DebugLogUploader new]; self.currentUploader = [DebugLogUploader new];
[self.currentUploader uploadFileWithURL:[NSURL fileURLWithPath:zipFilePath] [self.currentUploader uploadFileWithURL:[NSURL fileURLWithPath:zipFilePath]
mimeType:@"application/zip" mimeType:OWSMimeTypeApplicationZip
success:^(DebugLogUploader *uploader, NSURL *url) { success:^(DebugLogUploader *uploader, NSURL *url) {
if (uploader != weakSelf.currentUploader) { if (uploader != weakSelf.currentUploader) {
// Ignore events from obsolete uploaders. // Ignore events from obsolete uploaders.

@ -255,6 +255,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
} }
}(); }();
DDLogInfo(@"%@ Migrating setting - System Call Log Enabled: %d", self.logTag, shouldLogCallsInRecents);
[self setValueForKey:OWSPreferencesKeySystemCallLogEnabled [self setValueForKey:OWSPreferencesKeySystemCallLogEnabled
toValue:@(shouldLogCallsInRecents) toValue:@(shouldLogCallsInRecents)
transaction:transaction]; transaction:transaction];

@ -1,10 +1,11 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
extern NSString *const OWSMimeTypeApplicationOctetStream; extern NSString *const OWSMimeTypeApplicationOctetStream;
extern NSString *const OWSMimeTypeApplicationZip;
extern NSString *const OWSMimeTypeImagePng; extern NSString *const OWSMimeTypeImagePng;
extern NSString *const OWSMimeTypeOversizeTextMessage; extern NSString *const OWSMimeTypeOversizeTextMessage;
extern NSString *const OWSMimeTypeUnknownForTests; extern NSString *const OWSMimeTypeUnknownForTests;

@ -19,6 +19,7 @@ NSString *const OWSMimeTypeApplicationOctetStream = @"application/octet-stream";
NSString *const OWSMimeTypeImagePng = @"image/png"; NSString *const OWSMimeTypeImagePng = @"image/png";
NSString *const OWSMimeTypeOversizeTextMessage = @"text/x-signal-plain"; NSString *const OWSMimeTypeOversizeTextMessage = @"text/x-signal-plain";
NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype"; NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
NSString *const OWSMimeTypeApplicationZip = @"application/zip";
NSString *const kOversizeTextAttachmentUTI = @"org.whispersystems.oversize-text-attachment"; NSString *const kOversizeTextAttachmentUTI = @"org.whispersystems.oversize-text-attachment";
NSString *const kOversizeTextAttachmentFileExtension = @"txt"; NSString *const kOversizeTextAttachmentFileExtension = @"txt";
@ -1250,7 +1251,7 @@ NSString *const kSyncMessageFileExtension = @"bin";
@"application/yang" : @"yang", @"application/yang" : @"yang",
@"application/yin+xml" : @"yin", @"application/yin+xml" : @"yin",
@"application/ynd.ms-pkipko" : @"pko", @"application/ynd.ms-pkipko" : @"pko",
@"application/zip" : @"zip", OWSMimeTypeApplicationZip : @"zip",
@"audio/aac" : @"aac", @"audio/aac" : @"aac",
@"audio/adpcm" : @"adp", @"audio/adpcm" : @"adp",
@"audio/aiff" : @"aiff", @"audio/aiff" : @"aiff",
@ -2557,7 +2558,7 @@ NSString *const kSyncMessageFileExtension = @"bin";
@"z7" : @"application/x-zmachine", @"z7" : @"application/x-zmachine",
@"z8" : @"application/x-zmachine", @"z8" : @"application/x-zmachine",
@"zaz" : @"application/vnd.zzazz.deck+xml", @"zaz" : @"application/vnd.zzazz.deck+xml",
@"zip" : @"application/zip", @"zip" : OWSMimeTypeApplicationZip,
@"zir" : @"application/vnd.zul", @"zir" : @"application/vnd.zul",
@"zirz" : @"application/vnd.zul", @"zirz" : @"application/vnd.zul",
@"zmm" : @"application/vnd.handheld-entertainment+xml", @"zmm" : @"application/vnd.handheld-entertainment+xml",

Loading…
Cancel
Save