IM: Detect not signed terms error

(cherry picked from commit 80877eabafc2184ef55c279d2a8f2db10d9735e3)
This commit is contained in:
manuroe
2019-08-02 12:49:00 +02:00
parent 70c7b27550
commit adf27dee3b
2 changed files with 25 additions and 2 deletions
+22 -1
View File
@@ -513,6 +513,8 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
MXHTTPOperation *operation;
NSString *userId = mxSession.myUser.userId;
NSLog(@"[WidgetManager] registerForScalarToken");
WidgetManagerConfig *config = [self configForUser:userId];
if (!config.hasUrls)
{
@@ -539,6 +541,10 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
MXJSONModelSetString(scalarToken, JSONResponse[@"scalar_token"])
config.scalarToken = scalarToken;
// Validate it (this mostly checks to see if the IM needs us to agree to some terms)
// TODO
// return this._checkToken(tokenObject);
self->configs[userId] = config;
[self saveConfigs];
@@ -622,7 +628,22 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
}
else if (failure)
{
failure(error);
MXError *mxError = [[MXError alloc] initWithNSError:error];
if ([mxError.errcode isEqualToString:kMXErrCodeStringTermsNotSigned])
{
NSLog(@"[WidgetManager] validateScalarToke. Error: Need to accept terms");
NSError *termsNotSignedError = [NSError errorWithDomain:WidgetManagerErrorDomain
code:WidgetManagerErrorCodeTermsNotSigned
userInfo:@{
NSLocalizedDescriptionKey:error.userInfo[NSLocalizedDescriptionKey]
}];
failure(termsNotSignedError);
}
else
{
failure(error);
}
}
}];
}