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

Add debugging for Issue 2447 #2448

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/onedrive.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,14 @@ class OneDriveWebhook {
cgi.setResponseContentType("text/plain");

if ("validationToken" in cgi.get) {
log.vdebug("validationToken provided within cgi.get");
// For validation requests, respond with the validation token passed in the query string
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/concepts/webhook-receiver-validation-request
cgi.write(cgi.get["validationToken"]);

auto validationToken = cgi.get["validationToken"];
log.vdebug("validationToken: ", validationToken);

cgi.write(validationToken);
log.log("Webhook: handled validation request");
} else {
// Notifications don't include any information about the changes that triggered them.
Expand Down Expand Up @@ -417,7 +422,10 @@ final class OneDriveApi
// SharePoint Queries
log.vdebug("Configured siteSearchUrl: ", siteSearchUrl);
log.vdebug("Configured siteDriveUrl: ", siteDriveUrl);


// Webhook Queries
log.vdebug("Configured subscriptionUrl: ",subscriptionUrl);

// Configure the User Agent string
if (cfg.getValueString("user_agent") == "") {
// Application User Agent string defaults
Expand Down Expand Up @@ -1029,6 +1037,8 @@ final class OneDriveApi
} else {
resourceItem = "/me/drive/root";
}
// Debug output for the subscription resource item
log.vdebug("Setting subsription resourceItem as: ", resourceItem);

// create JSON request to create webhook subscription
const JSONValue request = [
Expand All @@ -1038,10 +1048,17 @@ final class OneDriveApi
"expirationDateTime": expirationDateTime.toISOExtString(),
"clientState": randomUUID().toString()
];

// Debug output of the full required for the webhook subscription creation
log.vdebug("Create subsription request: ", request.toString());
http.addRequestHeader("Content-Type", "application/json");
JSONValue response;

// Debug output of the subscription URL we are using for this action
log.vdebug("Subsription URL: ", url);

try {
// This is expecting a JSON response
response = post(url, request.toString());
} catch (OneDriveException e) {
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
Expand Down