This commit is contained in:
Timothy Jaeryang Baek 2025-07-12 02:38:52 +04:00
parent b52a162597
commit 4351702587
2 changed files with 64 additions and 58 deletions

View file

@ -74,10 +74,9 @@ def override_static(path: str, content: str):
def get_license_data(app, key): def get_license_data(app, key):
if key: def handler(u):
try:
res = requests.post( res = requests.post(
"https://api.openwebui.com/api/v1/license/", f"{u}/api/v1/license/",
json={"key": key, "version": "1"}, json={"key": key, "version": "1"},
timeout=5, timeout=5,
) )
@ -99,6 +98,13 @@ def get_license_data(app, key):
log.error( log.error(
f"License: retrieval issue: {getattr(res, 'text', 'unknown error')}" f"License: retrieval issue: {getattr(res, 'text', 'unknown error')}"
) )
if key:
us = ["https://api.openwebui.com", "https://licenses.api.openwebui.com"]
try:
for u in us:
if handler(u):
return True
except Exception as ex: except Exception as ex:
log.exception(f"License: Uncaught Exception: {ex}") log.exception(f"License: Uncaught Exception: {ex}")
return False return False

View file

@ -158,6 +158,41 @@
this.setupEventListeners(); this.setupEventListeners();
} }
generateUserColor() {
const colors = [
'#FF6B6B',
'#4ECDC4',
'#45B7D1',
'#96CEB4',
'#FFEAA7',
'#DDA0DD',
'#98D8C8',
'#F7DC6F',
'#BB8FCE',
'#85C1E9'
];
return colors[Math.floor(Math.random() * colors.length)];
}
joinDocument() {
const userColor = this.generateUserColor();
this.socket.emit('yjs:document:join', {
document_id: this.documentId,
user_id: this.user?.id,
user_name: this.user?.name,
user_color: userColor
});
// Set user awareness info
if (awareness && this.user) {
awareness.setLocalStateField('user', {
name: `${this.user.name}`,
color: userColor,
id: this.socket.id
});
}
}
setupEventListeners() { setupEventListeners() {
// Listen for document updates from server // Listen for document updates from server
this.socket.on('yjs:document:update', (data) => { this.socket.on('yjs:document:update', (data) => {
@ -254,41 +289,6 @@
} }
} }
generateUserColor() {
const colors = [
'#FF6B6B',
'#4ECDC4',
'#45B7D1',
'#96CEB4',
'#FFEAA7',
'#DDA0DD',
'#98D8C8',
'#F7DC6F',
'#BB8FCE',
'#85C1E9'
];
return colors[Math.floor(Math.random() * colors.length)];
}
joinDocument() {
const userColor = this.generateUserColor();
this.socket.emit('yjs:document:join', {
document_id: this.documentId,
user_id: this.user?.id,
user_name: this.user?.name,
user_color: userColor
});
// Set user awareness info
if (awareness && this.user) {
awareness.setLocalStateField('user', {
name: `${this.user.name}`,
color: userColor,
id: this.socket.id
});
}
}
onConnect() { onConnect() {
this.isConnected = true; this.isConnected = true;
this.joinDocument(); this.joinDocument();