Skip to content

Commit e2d60bd

Browse files
committed
chore: format
1 parent c2eada3 commit e2d60bd

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

backend/open_webui/utils/filter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ async def process_filter_functions(
6565
**(valves if valves else {})
6666
)
6767

68-
6968
try:
7069
# Prepare parameters
7170
sig = inspect.signature(handler)

src/lib/utils/onedrive-file-picker.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let CLIENT_ID = '';
66

77
async function getCredentials() {
88
if (CLIENT_ID) return;
9-
9+
1010
const response = await fetch('/api/config');
1111
if (!response.ok) {
1212
throw new Error('Failed to fetch OneDrive credentials');
@@ -18,7 +18,6 @@ async function getCredentials() {
1818
}
1919
}
2020

21-
2221
let msalInstance: PublicClientApplication | null = null;
2322

2423
// Initialize MSAL authentication
@@ -27,24 +26,26 @@ async function initializeMsal() {
2726
if (!CLIENT_ID) {
2827
await getCredentials();
2928
}
30-
29+
3130
const msalParams = {
3231
auth: {
3332
authority: 'https://login.microsoftonline.com/consumers',
3433
clientId: CLIENT_ID
3534
}
3635
};
37-
36+
3837
if (!msalInstance) {
3938
msalInstance = new PublicClientApplication(msalParams);
4039
if (msalInstance.initialize) {
4140
await msalInstance.initialize();
4241
}
4342
}
44-
43+
4544
return msalInstance;
4645
} catch (error) {
47-
throw new Error('MSAL initialization failed: ' + (error instanceof Error ? error.message : String(error)));
46+
throw new Error(
47+
'MSAL initialization failed: ' + (error instanceof Error ? error.message : String(error))
48+
);
4849
}
4950
}
5051

@@ -57,14 +58,14 @@ async function getToken(): Promise<string> {
5758
if (!msalInstance) {
5859
throw new Error('MSAL not initialized');
5960
}
60-
61+
6162
const resp = await msalInstance.acquireTokenSilent(authParams);
6263
accessToken = resp.accessToken;
6364
} catch (err) {
6465
if (!msalInstance) {
6566
throw new Error('MSAL not initialized');
6667
}
67-
68+
6869
try {
6970
const resp = await msalInstance.loginPopup(authParams);
7071
msalInstance.setActiveAccount(resp.account);
@@ -73,14 +74,17 @@ async function getToken(): Promise<string> {
7374
accessToken = resp2.accessToken;
7475
}
7576
} catch (popupError) {
76-
throw new Error('Failed to login: ' + (popupError instanceof Error ? popupError.message : String(popupError)));
77+
throw new Error(
78+
'Failed to login: ' +
79+
(popupError instanceof Error ? popupError.message : String(popupError))
80+
);
7781
}
7882
}
79-
83+
8084
if (!accessToken) {
8185
throw new Error('Failed to acquire access token');
8286
}
83-
87+
8488
return accessToken;
8589
}
8690

@@ -106,7 +110,6 @@ const params = {
106110
}
107111
};
108112

109-
110113
// Download file from OneDrive
111114
async function downloadOneDriveFile(fileInfo: any): Promise<Blob> {
112115
const accessToken = await getToken();
@@ -228,17 +231,17 @@ export async function openOneDrivePicker(): Promise<any | null> {
228231
if (!authToken) {
229232
return reject(new Error('Failed to acquire access token'));
230233
}
231-
234+
232235
pickerWindow = window.open('', 'OneDrivePicker', 'width=800,height=600');
233236
if (!pickerWindow) {
234237
return reject(new Error('Failed to open OneDrive picker window'));
235238
}
236-
239+
237240
const queryString = new URLSearchParams({
238241
filePicker: JSON.stringify(params)
239242
});
240243
const url = `${baseUrl}?${queryString.toString()}`;
241-
244+
242245
const form = pickerWindow.document.createElement('form');
243246
form.setAttribute('action', url);
244247
form.setAttribute('method', 'POST');
@@ -247,10 +250,10 @@ export async function openOneDrivePicker(): Promise<any | null> {
247250
input.setAttribute('name', 'access_token');
248251
input.setAttribute('value', authToken);
249252
form.appendChild(input);
250-
253+
251254
pickerWindow.document.body.appendChild(form);
252255
form.submit();
253-
256+
254257
window.addEventListener('message', handleWindowMessage);
255258
} catch (err) {
256259
if (pickerWindow) {
@@ -267,14 +270,14 @@ export async function openOneDrivePicker(): Promise<any | null> {
267270
// Pick and download file from OneDrive
268271
export async function pickAndDownloadFile(): Promise<{ blob: Blob; name: string } | null> {
269272
const pickerResult = await openOneDrivePicker();
270-
273+
271274
if (!pickerResult || !pickerResult.items || pickerResult.items.length === 0) {
272275
return null;
273276
}
274-
277+
275278
const selectedFile = pickerResult.items[0];
276279
const blob = await downloadOneDriveFile(selectedFile);
277-
280+
278281
return { blob, name: selectedFile.name };
279282
}
280283

0 commit comments

Comments
 (0)