-
Notifications
You must be signed in to change notification settings - Fork 142
feat: Video calling support using WebRTC #57
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
base: main
Are you sure you want to change the base?
Changes from all commits
65d9ac3
f0545c0
35068b5
cf6305c
ab0349e
799285a
a76b22b
f14dbb6
22d4441
6de93a9
3b9e722
8975554
b1ec48e
c843a35
aa325fb
ca0ec78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| from datetime import datetime, timezone | ||
| from db.db import AsyncSessionLocal | ||
| from models.models import User | ||
|
|
||
|
|
||
| async def seed_db(): | ||
| users = [ | ||
| { | ||
| "id": "aabb1fd8-ba93-4e8c-976e-35e5c40b809c", | ||
| "username": "creator1", | ||
| "email": "[email protected]", | ||
| "password": "password123", | ||
| "role": "creator", | ||
| "bio": "Lifestyle and travel content creator", | ||
| }, | ||
| { | ||
| "id": "6dbfcdd5-795f-49c1-8f7a-a5538b8c6f6f", | ||
| "username": "brand1", | ||
| "email": "[email protected]", | ||
| "password": "password123", | ||
| "role": "brand", | ||
| "bio": "Sustainable fashion brand looking for influencers", | ||
| }, | ||
| ] | ||
|
|
||
| # Insert or update the users | ||
| async with AsyncSessionLocal() as session: | ||
| for user_data in users: | ||
| # Check if user exists | ||
| existing_user = await session.execute( | ||
| User.__table__.select().where(User.email == user_data["email"]) | ||
| ) | ||
| existing_user = existing_user.scalar_one_or_none() | ||
|
Comment on lines
+30
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use ORM query methods instead of raw SQL. The code is using raw SQL table select instead of the proper ORM query methods, which is less maintainable and type-safe. - existing_user = await session.execute(
- User.__table__.select().where(User.email == user_data["email"])
- )
- existing_user = existing_user.scalar_one_or_none()
+ from sqlalchemy import select
+ stmt = select(User).where(User.email == user_data["email"])
+ result = await session.execute(stmt)
+ existing_user = result.scalar_one_or_none()🤖 Prompt for AI Agents |
||
|
|
||
| if existing_user: | ||
| continue | ||
| else: | ||
| # Create new user | ||
| user = User( | ||
| id=user_data["id"], | ||
| username=user_data["username"], | ||
| email=user_data["email"], | ||
| password_hash=user_data[ | ||
| "password" | ||
| ], # Using plain password directly | ||
| role=user_data["role"], | ||
| bio=user_data["bio"], | ||
| ) | ||
| session.add(user) | ||
| print(f"Created user: {user_data['email']}") | ||
|
|
||
| # Commit the session | ||
| await session.commit() | ||
| print("✅ Users seeded successfully.") | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||||||||
| from sqlalchemy import Column, String, ForeignKey, DateTime, Enum, UniqueConstraint | ||||||||||||||||
| from sqlalchemy.orm import relationship | ||||||||||||||||
| from datetime import datetime, timezone | ||||||||||||||||
| from db.db import Base | ||||||||||||||||
| import uuid | ||||||||||||||||
| import enum | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_uuid(): | ||||||||||||||||
| return str(uuid.uuid4()) | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+9
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove duplicate This function is already defined in Replace the duplicate function with an import: -def generate_uuid():
- return str(uuid.uuid4())
+from models.models import generate_uuid📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| class MessageStatus(enum.Enum): | ||||||||||||||||
| SENT = "sent" | ||||||||||||||||
| DELIVERED = "delivered" | ||||||||||||||||
| SEEN = "seen" | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class ChatList(Base): | ||||||||||||||||
| __tablename__ = "chat_list" | ||||||||||||||||
|
|
||||||||||||||||
| id = Column(String, primary_key=True, default=generate_uuid) | ||||||||||||||||
| user1_id = Column(String, ForeignKey("users.id"), nullable=False) | ||||||||||||||||
| user2_id = Column(String, ForeignKey("users.id"), nullable=False) | ||||||||||||||||
| last_message_time = Column( | ||||||||||||||||
| DateTime(timezone=True), default=lambda: datetime.now(timezone.utc) | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| user1 = relationship("User", foreign_keys=[user1_id], backref="chatlist_user1") | ||||||||||||||||
| user2 = relationship("User", foreign_keys=[user2_id], backref="chatlist_user2") | ||||||||||||||||
|
|
||||||||||||||||
| __table_args__ = (UniqueConstraint("user1_id", "user2_id", name="unique_chat"),) | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class ChatMessage(Base): | ||||||||||||||||
| __tablename__ = "chat_messages" | ||||||||||||||||
|
|
||||||||||||||||
| id = Column(String, primary_key=True, default=generate_uuid) | ||||||||||||||||
| sender_id = Column(String, ForeignKey("users.id"), nullable=False) | ||||||||||||||||
| receiver_id = Column(String, ForeignKey("users.id"), nullable=False) | ||||||||||||||||
| message = Column(String, nullable=False) | ||||||||||||||||
| status = Column( | ||||||||||||||||
| Enum(MessageStatus), default=MessageStatus.SENT | ||||||||||||||||
| ) # Using the enum class | ||||||||||||||||
| created_at = Column( | ||||||||||||||||
| DateTime(timezone=True), default=lambda: datetime.now(timezone.utc) | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| sender = relationship("User", foreign_keys=[sender_id], backref="sent_messages") | ||||||||||||||||
| receiver = relationship( | ||||||||||||||||
| "User", foreign_keys=[receiver_id], backref="received_messages" | ||||||||||||||||
| ) | ||||||||||||||||
| chat_list_id = Column(String, ForeignKey("chat_list.id"), nullable=False) | ||||||||||||||||
| chat = relationship("ChatList", backref="messages") | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical security issue: Plain text passwords are being stored.
The code is storing plain text passwords directly in the
password_hashfield without any hashing. This creates a serious security vulnerability where user credentials are exposed in the database.Hash the passwords before storing them:
Also applies to: 20-20, 43-45
🤖 Prompt for AI Agents