Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request signaling server trial #3620

Merged
merged 21 commits into from Jun 10, 2020

Conversation

MorrisJobke
Copy link
Member

@MorrisJobke MorrisJobke commented May 19, 2020

This is a little form inside the talk settings to request a trial from the newly announced hosted signaling server by Struktur AG (see https://nextcloud.com/blog/open-sourcing-talk-back-end-rc-of-talk-9-brings-lots-of-improvements/).

As of now it looks like this:

Bildschirmfoto 2020-05-19 um 14 12 50

Things that need to be done:

  • select fields for language and country (based on the lists we have for the personal settings maybe)
  • view for status of the requested trial - basically once the trial is requested it is in "pending" state and it just needs to display the current status (it's a single request to the API and then showing that content)
  • fetching the current status (see above) and caching this on the Nextcloud server for some minutes
  • dropping the status if the account was deleted on the server side (server here means Struktur's server) replaced by an "delete account button"
  • periodically fetching the status if it is pending to check if the credentials are available and then fill them into the signaling server settings
  • set the correct API server URL
  • send admins notifications about updated signaling server credentials
  • add warning text that the signaling server trial will replace added signaling servers
  • button to delete account

Pending things to decide:

Copy link
Member

@fancycode fancycode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some feedback and please change the wording from "trail" to "trial".

lib/Controller/HostedSignalingServerController.php Outdated Show resolved Hide resolved
@MorrisJobke MorrisJobke changed the title Request signaling server trail Request signaling server trial May 20, 2020
@MorrisJobke MorrisJobke force-pushed the feature/noid/request-signaling-server-trail branch from 7667c16 to 2ea76a4 Compare May 20, 2020 14:18
@MorrisJobke MorrisJobke force-pushed the feature/noid/request-signaling-server-trail branch from 2ea76a4 to ddae0df Compare May 20, 2020 14:33
@MorrisJobke
Copy link
Member Author

Any idea how to make the whole parsing mess in https://github.com/nextcloud/spreed/pull/3620/files#diff-a862c0a156d4c35c3617618db80227a4R85-R257 a lot more structured? Maybe @rullzer, @kesselb or @ChristophWurst? I feel really bad about this mess of code, but it's just quite some cases you want to have covered and all have different error handling 🙈 some throw exceptions, some return empty values, some require to call separate functions to fetch the error (looking at you json_decode)

And then you want to have a bunch of logging and a bunch of user facing error messages

And then there is basically the same again. I would like to extract those two big blocks (above and below // account is now properly requested) into private methods for better readability. Also the second part needs to be executed from a background job as well and thus would be nice to have in a service class.

@MorrisJobke MorrisJobke force-pushed the feature/noid/request-signaling-server-trail branch from 1396135 to 8d9214a Compare May 22, 2020 12:18
@MorrisJobke
Copy link
Member Author

Any idea how to make the whole parsing mess in https://github.com/nextcloud/spreed/pull/3620/files#diff-a862c0a156d4c35c3617618db80227a4R85-R257 a lot more structured? Maybe @rullzer, @kesselb or @ChristophWurst? I feel really bad about this mess of code, but it's just quite some cases you want to have covered and all have different error handling 🙈 some throw exceptions, some return empty values, some require to call separate functions to fetch the error (looking at you json_decode)

And then you want to have a bunch of logging and a bunch of user facing error messages

And then there is basically the same again. I would like to extract those two big blocks (above and below // account is now properly requested) into private methods for better readability. Also the second part needs to be executed from a background job as well and thus would be nice to have in a service class.

I moved them to a service class that translates all cases in one of two exceptions (one for API, connection or response errors the user can't solve and one for user problems like wrong input or non-public server).

Now the controller is far better readable and only does the actual logic it needs to do.

try {
$registerAccountData = new RegisterAccountData(
$url,
$name,
$email,
$language,
$country
);
$accountId = $this->hostedSignalingServerService->registerAccount($registerAccountData);
$accountInfo = $this->hostedSignalingServerService->fetchAccountInfo($accountId);
$this->config->setAppValue('spreed', 'hosted-signaling-server-account', json_encode($accountInfo));
} catch (HostedSignalingServerAPIException $e) { // API or connection issues
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
} catch (HostedSignalingServerInputException $e) { // user solvable issues
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
}
return new DataResponse($accountInfo);

@MorrisJobke MorrisJobke force-pushed the feature/noid/request-signaling-server-trail branch 2 times, most recently from 6aa80ca to 8b0bf1b Compare May 26, 2020 10:24
@MorrisJobke
Copy link
Member Author

Most is done. Only one disclaimer sentence needs to be added that signaling server is overwritten. And we need to check how to drop accounts from Nextcloud again (I would do that if the Struktur API returns that the account was deleted).

@MorrisJobke
Copy link
Member Author

And we need to check how to drop accounts from Nextcloud again (I would do that if the Struktur API returns that the account was deleted).

Problem with this would be that then if the API is not reachable, but the webserver or proxy returns a 404 the account would also vanish. Maybe we should still add the option to delete the account? And only then remove it from the settings page?

@MorrisJobke
Copy link
Member Author

How to run this locally:

  • HPB service:
    • fetching the hpb-service code
    • comment the HTTPS check in api.go line 16: return NewValidationFailed("https_required")
    • run make build
    • run rm -rf accounts.sqlite3 && bin/spreed-hpbservice (that easily resets the state of the service on every new run)
  • run two nextcloud instances under different ports (if the built in web server is used, because they can only serve one concurrent request, but the authentication round trip of the hpb-services requires 2 concurrent)
    • php -S 0.0.0.0:8001 and php -S 0.0.0.0:8002
  • build and install Talk

Testing:

  • go to admin talk settings and enter the IP and port of the other web server (the one you don't use to browse the admin settings)
  • do further tests

|| !isset($data['owner']['email'])
|| !isset($data['owner']['language'])
|| !isset($data['owner']['country'])
/* TODO they are not yet returned
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fancycode While doing a full test run I noticed that those fields are not yet returned.

@nickvergessen Either leave it as it is now (the limits are only shown in the UI if present anyways) or coordinate with @fancycode if they are added.

// and thus the cached value in the config object would trigger an UPDATE
// instead of an INSERT if there is another request to the API server
$this->config->deleteAppValue('spreed', 'hosted-signaling-server-nonce');
} catch (ClientException $e) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error case handling is very similar for all three requests. This maybe refactored a bit, but I don't want to mix them too much as some status codes are different for the three requests. So it's up to you to move it all in one method or leave it that verbose.

tr :first-child {
opacity: .5;
}
.delete {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some custom styling for the delete button (I used the one from the "enable unsupported app" in the app management).

</p>
<button class="button delete"
:disabled="loading"
@click="deleteAccount">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want a modal here to ask if the account really should be deleted. Up to you. Also after deletion a re-registration is not possible.

@MorrisJobke MorrisJobke marked this pull request as ready for review May 29, 2020 20:58
@MorrisJobke MorrisJobke force-pushed the feature/noid/request-signaling-server-trail branch 2 times, most recently from 49dd7ef to f549b56 Compare May 29, 2020 21:05
lib/DataObjects/AccountId.php Show resolved Hide resolved
},

beforeMount() {
const state = loadState('talk', 'hosted_signaling_server_prefill')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just do this in data()

@nickvergessen nickvergessen self-assigned this Jun 8, 2020
MorrisJobke and others added 17 commits June 10, 2020 16:26
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
… server trial - without notifciations

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
…count

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the feature/noid/request-signaling-server-trail branch from 675dfd7 to 09811cd Compare June 10, 2020 14:35
Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works

@nickvergessen nickvergessen added 4. to release feature: settings ⚙️ Settings and config related issues feature: signaling 📶 Internal and external signaling backends and removed 2. developing labels Jun 10, 2020
@nickvergessen nickvergessen merged commit 2120280 into master Jun 10, 2020
@nickvergessen nickvergessen deleted the feature/noid/request-signaling-server-trail branch June 10, 2020 15:27
@nickvergessen nickvergessen mentioned this pull request Jun 12, 2020
@MorrisJobke
Copy link
Member Author

Thanks @nickvergessen 🚀

@MorrisJobke MorrisJobke removed their assignment Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release enhancement feature: settings ⚙️ Settings and config related issues feature: signaling 📶 Internal and external signaling backends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants