Compare commits
No commits in common. "809609acd0845950a296314c0327ffb3f5cedaa1" and "977e47cd7292c79c388092785e027d0492255ebc" have entirely different histories.
809609acd0
...
977e47cd72
|
|
@ -7,8 +7,6 @@ from open_webui.internal.db import Base, JSONField, get_db
|
||||||
from open_webui.models.chats import Chats
|
from open_webui.models.chats import Chats
|
||||||
from open_webui.models.groups import Groups
|
from open_webui.models.groups import Groups
|
||||||
|
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
|
||||||
import random
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
from sqlalchemy import BigInteger, Column, String, Text, JSON
|
from sqlalchemy import BigInteger, Column, String, Text, JSON
|
||||||
|
|
@ -344,36 +342,6 @@ class UsersTable:
|
||||||
users = db.query(User).filter(User.id.in_(user_ids)).all()
|
users = db.query(User).filter(User.id.in_(user_ids)).all()
|
||||||
return [user.id for user in users]
|
return [user.id for user in users]
|
||||||
|
|
||||||
def generate_letter_image(letter, image_size=(200, 200), font_size=100, font_path=None):
|
|
||||||
"""
|
|
||||||
Generuje obraz z podaną literą i losowym kolorem tła.
|
|
||||||
|
|
||||||
:param letter: Pojedyncza litera do wyświetlenia
|
|
||||||
:param image_size: Rozmiar obrazu (szerokość, wysokość)
|
|
||||||
:param font_size: Rozmiar czcionki
|
|
||||||
:param font_path: Ścieżka do pliku czcionki (jeśli None, używana jest domyślna)
|
|
||||||
"""
|
|
||||||
if not isinstance(letter, str) or len(letter) != 1:
|
|
||||||
raise ValueError("Parametr 'letter' musi być pojedynczym znakiem.")
|
|
||||||
|
|
||||||
background_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
|
|
||||||
text_color = (255, 255, 255) # Biały kolor czcionki
|
|
||||||
|
|
||||||
image = Image.new("RGB", image_size, background_color)
|
|
||||||
draw = ImageDraw.Draw(image)
|
|
||||||
|
|
||||||
try:
|
|
||||||
font = ImageFont.truetype(font_path if font_path else "arial.ttf", font_size)
|
|
||||||
except IOError:
|
|
||||||
font = ImageFont.load_default()
|
|
||||||
|
|
||||||
text_width, text_height = draw.textsize(letter, font=font)
|
|
||||||
text_x = (image_size[0] - text_width) // 2
|
|
||||||
text_y = (image_size[1] - text_height) // 2
|
|
||||||
|
|
||||||
draw.text((text_x, text_y), letter, font=font, fill=text_color)
|
|
||||||
return image
|
|
||||||
|
|
||||||
def update_user_profile(self, id: str, name: str, profile_image_url: str, role: str, permissions: Optional[dict] = None, subscription: Optional[List[str]] = None) -> bool:
|
def update_user_profile(self, id: str, name: str, profile_image_url: str, role: str, permissions: Optional[dict] = None, subscription: Optional[List[str]] = None) -> bool:
|
||||||
try:
|
try:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
|
|
|
||||||
|
|
@ -320,11 +320,6 @@ class OAuthManager:
|
||||||
print(user_data.get("permissions"))
|
print(user_data.get("permissions"))
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
|
|
||||||
generated_image = Users.generate_letter_image()
|
|
||||||
|
|
||||||
print(generated_image)
|
|
||||||
|
|
||||||
user_count = Users.get_num_users()
|
user_count = Users.get_num_users()
|
||||||
|
|
||||||
# If the user does not exist, check if signups are enabled
|
# If the user does not exist, check if signups are enabled
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue