mirror of
https://github.com/abraunegg/onedrive
synced 2026-03-14 14:35:46 +01:00
Update PR
* Update PR
This commit is contained in:
parent
691e92085b
commit
b1e86783ed
2 changed files with 1 additions and 67 deletions
|
|
@ -1130,6 +1130,7 @@ class OneDriveApi {
|
|||
|
||||
// Obtain the Websocket Notification URL
|
||||
JSONValue obtainWebSocketNotificationURL() {
|
||||
addLogEntry("Request a Socket.IO Subscription Endpoint: " ~ websocketEndpoint);
|
||||
return get(websocketEndpoint);
|
||||
}
|
||||
|
||||
|
|
|
|||
67
src/util.d
67
src/util.d
|
|
@ -1900,70 +1900,3 @@ void displayFunctionProcessingTime(string functionName, SysTime functionStartTim
|
|||
string processingTime = format("[%s] Application Function '%s' Processing Time = %.4f Seconds", strip(logKey), strip(functionName), functionDurationAsSeconds);
|
||||
addLogEntry(processingTime);
|
||||
}
|
||||
|
||||
// Convert the Graph notificationUrl into a socket.io WS endpoint:
|
||||
// https://host/...?... -> wss://host/socket.io/?EIO=4&transport=websocket&...
|
||||
string toSocketIoWsUrl(string notificationUrl) {
|
||||
|
||||
// DEBUG REMOVE LATER
|
||||
addLogEntry("Input URL to toSocketIoWsUrl: " ~ notificationUrl);
|
||||
|
||||
|
||||
// ---- scheme ----
|
||||
auto iScheme = notificationUrl.countUntil("://");
|
||||
if (iScheme == notificationUrl.length) return notificationUrl; // fallback (malformed input)
|
||||
auto scheme = notificationUrl[0 .. iScheme];
|
||||
auto rest = notificationUrl[iScheme + 3 .. $]; // after "://"
|
||||
|
||||
// ---- authority + path+query ----
|
||||
// authority ends at first '/' or '?' (whichever comes first)
|
||||
auto iSlash = rest.countUntil("/");
|
||||
auto iQmark = rest.countUntil("?");
|
||||
size_t cut;
|
||||
if (iSlash == rest.length && iQmark == rest.length) {
|
||||
cut = rest.length;
|
||||
} else if (iSlash == rest.length) {
|
||||
cut = iQmark;
|
||||
} else if (iQmark == rest.length) {
|
||||
cut = iSlash;
|
||||
} else {
|
||||
cut = (iSlash < iQmark) ? iSlash : iQmark;
|
||||
}
|
||||
auto authority = rest[0 .. cut];
|
||||
auto pathQuery = rest[cut .. $]; // may be "", starts with "/" or "?"
|
||||
|
||||
// ---- extract original query (ignore original path; we force /socket.io/) ----
|
||||
string query;
|
||||
auto iq = pathQuery.countUntil("?");
|
||||
if (iq != pathQuery.length) {
|
||||
query = pathQuery[iq + 1 .. $]; // after '?'
|
||||
} else {
|
||||
query = "";
|
||||
}
|
||||
|
||||
// ---- scheme map ----
|
||||
string wsScheme = (scheme == "https") ? "wss" : (scheme == "http" ? "ws" : scheme);
|
||||
|
||||
// ---- keep all original params EXCEPT EIO and transport; we’ll set them explicitly ----
|
||||
string[] kept;
|
||||
if (query.length) {
|
||||
foreach (p; query.split("&")) {
|
||||
if (p.length == 0) continue;
|
||||
if (p.startsWith("EIO=")) continue;
|
||||
if (p.startsWith("transport=")) continue;
|
||||
kept ~= p;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- final query: required first, then preserved params ----
|
||||
string finalQuery = "EIO=4&transport=websocket";
|
||||
if (kept.length) finalQuery ~= "&" ~ kept.join("&");
|
||||
|
||||
string resultURL = wsScheme ~ "://" ~ authority ~ "/socket.io/?" ~ finalQuery;
|
||||
|
||||
addLogEntry("Output URL from toSocketIoWsUrl: " ~ resultURL);
|
||||
|
||||
|
||||
// ---- build final URL ----
|
||||
return resultURL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue