Skip to content

Commit

Permalink
Cleanup and release 8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
roznet committed Oct 9, 2023
1 parent 0adbce5 commit 5fdc906
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 20 deletions.
6 changes: 3 additions & 3 deletions ConnectStats.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6657,7 +6657,7 @@
CODE_SIGN_ENTITLEMENTS = ConnectStats/ConnectStats.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 55;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = M7QSSF3624;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -6712,7 +6712,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 55;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = M7QSSF3624;
ENABLE_TESTABILITY = NO;
Expand Down Expand Up @@ -7151,7 +7151,7 @@
repositoryURL = "https://github.com/roznet/rzexternal";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.4;
minimumVersion = 1.0.5;
};
};
4221EDE626F091D3006049DE /* XCRemoteSwiftPackageReference "generic-json-swift" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/roznet/rzexternal",
"state" : {
"revision" : "369f04960e18085d549400c1f7a571af8d8f3935",
"version" : "1.0.4"
"revision" : "efce225e6616ab3eb5dac5470c470ecada2c0bc0",
"version" : "1.0.5"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion ConnectStats/src/GCActivitiesOrganizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ -(BOOL)checkIfActivityIsDuplicate:(GCActivity*)act{
GCActivity * other = [self findDuplicate:act];
if (other) {
gcDuplicate reason = [other testForDuplicate:act];
BOOL duplicateServiceIsPreferred = (reason == gcDuplicateSynchronizedService) && [act.service preferredOver:other.service];
BOOL duplicateServiceIsPreferred = (reason != gcDuplicateNotMatching) && [act.service preferredOver:other.service];

// don't record if already
if( self.duplicateActivityIds[act.activityId] == nil) {
Expand Down
5 changes: 5 additions & 0 deletions ConnectStats/src/GCActivity+Import.m
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,11 @@ -(void)parseStravaJson:(NSDictionary*)data{
NSString * garminId = [externalId substringFromIndex:[@"garmin_push_" length]];
self.externalServiceActivityId = [[GCService service:gcServiceGarmin] activityIdFromServiceId:garminId];
}

if([externalId isKindOfClass:[NSString class]] && [externalId hasPrefix:@"garmin_ping_"]){
NSString * garminId = [externalId substringFromIndex:[@"garmin_ping_" length]];
self.externalServiceActivityId = [[GCService service:gcServiceGarmin] activityIdFromServiceId:garminId];
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion ConnectStats/src/GCAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,11 @@ -(void)settingsUpdateCheck{
[self stravaSignout];
}
}

if( needToSaveSettings ){
[self saveSettings];
}

}


Expand Down
17 changes: 11 additions & 6 deletions ConnectStats/src/GCConnectStatsRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,14 @@ -(BOOL)checkNoErrors{
-(BOOL)isSignedIn{
// Always check token first as it's possible a previous req in the queue did log in and
// we don't want to present a second time.
if( ! self.oauthToken ){
if( !self.oauthToken || self.oauthToken.length == 0){
[self checkToken];
}
BOOL rv = self.oauthToken != nil && self.oauthTokenSecret != nil && self.userId != 0 && self.tokenId != 0;

//If signed in, we will still need an oauth1controller
// if not signed in, will be created in the sign in process
if( rv && ! self.oauth1Controller){
RZLog(RZLogInfo, @"check oauthbuild during isSignedIn");
[self buildOAuthController];
}
return rv;
Expand All @@ -151,7 +150,7 @@ -(BOOL)isSignedIn{
-(void)signIn{
if (self.oauthToken) {
if( self.userId == 0 || self.tokenId == 0){
[self signInConnectStatsStep];
[self signInGarminStep];
}else{
[self signInConnectStatsStep];
//[self processDone];
Expand All @@ -164,6 +163,7 @@ -(void)signIn{
-(void)signInConnectStatsStep{
gcWebConnectStatsConfig config = [GCAppGlobal webConnectsStatsConfig];
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:GCWebConnectStatsRegisterUser(config, self.oauthToken, self.oauthTokenSecret)]];
RZLog(RZLogInfo, @"ConnectStats Step with token %@", self.oauthToken);

[[[self sharedSession] dataTaskWithRequest:request completionHandler:
^(NSData * _Nullable data,
Expand All @@ -179,25 +179,32 @@ -(void)signInConnectStatsStep{
if( [responseTokenId respondsToSelector:@selector(integerValue)] ){
self.tokenId = responseTokenId.integerValue;
}else{
RZLog(RZLogWarning, @"Invalid token_id");
self.tokenId = 0;
}

NSNumber * responseUserId = response[@"cs_user_id"];
if( [responseUserId respondsToSelector:@selector(integerValue)] ){
self.userId = responseUserId.integerValue;
}else{
RZLog(RZLogWarning, @"Invalid cs_user_id");
self.userId = 0;
}
if( self.userId == 0 || self.tokenId == 0){
}

[[GCAppGlobal profile] configSet:CONFIG_CONNECTSTATS_TOKEN_ID intVal:self.tokenId];
[[GCAppGlobal profile] configSet:CONFIG_CONNECTSTATS_USER_ID intVal:self.userId];

if( self.userId != 0 && self.tokenId !=0){
RZLog(RZLogInfo, @"Successfully logged in userid=%@ tokenId=%@", @(self.userId), @(self.tokenId));
[[GCAppGlobal profile] serviceSuccess:gcServiceConnectStats set:YES];
if( [GCAppGlobal profile].pushNotificationEnabled){
[[GCAppGlobal web] addRequest:RZReturnAutorelease([[GCConnectStatsRequestRegisterNotifications alloc] init])];
}

}else{
RZLog(RZLogWarning, @"Invalid response %@", response);
}
[GCAppGlobal saveSettings];
}
Expand All @@ -210,7 +217,7 @@ -(void)signInConnectStatsStep{

-(void)buildOAuthController{
if( self.oauth1Controller == nil){
RZLog(RZLogInfo,@"start build oauth controller");
RZLog(RZLogInfo,@"building oauth controller");
NSError * error = nil;
NSData * credentials = [NSData dataWithContentsOfFile:[RZFileOrganizer bundleFilePath:@"credentials.json"] options:0 error:&error];
if( ! credentials ){
Expand All @@ -227,7 +234,6 @@ -(void)buildOAuthController{

if( !params[@"consumer_secret"] || [params[@"consumer_secret"] isEqualToString:@"***"]){
RZLog( RZLogError, @"Credentials not initialized properly, no consumer_secret");

}

self.oauth1Controller = [[[OAuth1Controller alloc] initWithServiceParameters:params] autorelease];
Expand All @@ -252,7 +258,6 @@ -(void)signInGarminStep{
[self.navigationController pushViewController:webCont animated:YES];
[webCont release];
[webView release];
RZLog(RZLogInfo, @"check oauthbuild during signinStep");
[self buildOAuthController];
[self.oauth1Controller loginWithWebView:webView completion:^(NSDictionary *oauthTokens, NSError *error) {
if (error != nil) {
Expand Down
4 changes: 4 additions & 0 deletions ConnectStats/src/GCConnectStatsRequestFitFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ -(NSString*)description{

-(BOOL)validAlternativeService{
BOOL rv = false;
if( [GCGarminReqBase killSwitchTriggered]){
return rv;
}

BOOL garminSuccess = [[GCAppGlobal profile] serviceSuccess:gcServiceGarmin];
if( garminSuccess && self.activity.externalServiceActivityId) {
GCService * service = [GCService serviceForActivityId:self.activity.externalServiceActivityId];
Expand Down
14 changes: 9 additions & 5 deletions ConnectStats/src/GCConnectStatsRequestLogin.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ -(void)process:(NSData *)theData andDelegate:(id<GCWebRequestDelegate>)delegate{
}else{
// result of validate user
NSData * jsonData = theData;
NSDictionary * info = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:nil];
if( [info isKindOfClass:[NSDictionary class]] && [info[@"cs_user_id"] respondsToSelector:@selector(integerValue)] && [info[@"cs_user_id"] integerValue] == self.userId){
RZLog(RZLogInfo, @"Validated user %@", info[@"cs_user_id"]);
[GCConnectStatsRequestRegisterNotifications register];
if( jsonData ){
NSDictionary * info = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:nil];
if( [info isKindOfClass:[NSDictionary class]] && [info[@"cs_user_id"] respondsToSelector:@selector(integerValue)] && [info[@"cs_user_id"] integerValue] == self.userId){
RZLog(RZLogInfo, @"Validated user %@", info[@"cs_user_id"]);
[GCConnectStatsRequestRegisterNotifications register];
}else{
RZLog(RZLogWarning, @"Invalid user %@ != %@", info[@"cs_user_id"], @(self.userId));
}
}else{
RZLog(RZLogWarning, @"Invalid user %@ != %@", info[@"cs_user_id"], @(self.userId));
RZLog(RZLogWarning, @"Not data for user validation");
}
[self processDone];
}
Expand Down
4 changes: 4 additions & 0 deletions ConnectStats/src/GCGarminRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ -(RemoteDownloadPrepareUrl)prepareUrlFunc{
};
}
-(id<GCWebRequest>)remediationReq{
// if disable don't try anything
if( [GCGarminReqBase killSwitchTriggered]){
return nil;
}
if (self.status==GCWebStatusAccessDenied) {
self.status = GCWebStatusOK;
self.stage = gcRequestStageDownload;
Expand Down
2 changes: 0 additions & 2 deletions ConnectStats/src/GCStravaRequestBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,10 @@ class GCStravaRequestBase: GCWebRequestStandard {
// Start with success
self.status = GCWebStatus.OK
if let url = self.stravaUrl() {
RZSLog.info("Start get url")
self.stravaAuth.client.get(url){ result in

switch result {
case .success(let response):
RZSLog.info("Start got url ok")
self.status = GCWebStatus.OK
if( !GCAppGlobal.profile().serviceSuccess(gcService.strava)) {
DispatchQueue.main.async {
Expand Down

0 comments on commit 5fdc906

Please sign in to comment.