Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/llm-bot/issue_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
such as tagging, closing, translating, or requesting more information.
"""

import json
import os
import sys
import json
from typing import List, Optional
from enum import Enum
from typing import List, Optional

from pydantic import BaseModel, Field
from a5.ai import LLM
from github import Github, Auth

from github import Auth, Github
from pydantic import BaseModel, Field

# ============================================================================
# Configuration
Expand Down Expand Up @@ -225,16 +224,16 @@ def apply_decision(self, decision: BotDecision):
# Add debug information section
comment_body += self._format_debug_section(decision)

print(f"\nPosting comment...")
print("\nPosting comment...")
self.issue.create_comment(comment_body)

# Close issue if needed
if decision.action == IssueAction.CLOSE:
print(f"\nClosing issue...")
print("\nClosing issue...")
self.issue.edit(state="closed")

# Always add bot-processed label to indicate the bot has taken action
print(f"\nAdding bot-processed label...")
print("\nAdding bot-processed label...")
self.issue.add_to_labels("bot-processed")

print(f"\n✅ Successfully processed issue #{self.issue_number}")
Expand Down
13 changes: 6 additions & 7 deletions .github/llm-bot/pr_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
"""

import os
import sys
import re
from typing import Optional, List, Dict, Any
import sys
from enum import Enum
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field
from a5.ai import LLM
from github import Github, Auth

from github import Auth, Github
from pydantic import BaseModel, Field

# ============================================================================
# Configuration
Expand Down Expand Up @@ -476,7 +475,7 @@ def apply_decision(self, decision: BotDecision):
"""
comment_body += self._format_debug_section(decision)

print(f"\nPosting release note comment...")
print("\nPosting release note comment...")
self.pr.create_issue_comment(comment_body)

else: # EXCLUDE
Expand All @@ -493,7 +492,7 @@ def apply_decision(self, decision: BotDecision):
"""
comment_body += self._format_debug_section(decision)

print(f"\nPosting exclusion comment...")
print("\nPosting exclusion comment...")
self.pr.create_issue_comment(comment_body)

print(f"\n✅ Successfully processed PR #{self.pr_number}")
Expand Down
8 changes: 7 additions & 1 deletion app/backend/src/couchers/servicers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from couchers.servicers.api import user_model_to_pb
from couchers.servicers.auth import create_session
from couchers.servicers.events import generate_event_delete_notifications
from couchers.servicers.notifications import disable_push_notifications_for_user
from couchers.servicers.threads import unpack_thread_id
from couchers.sql import to_bool, username_or_email_or_id
from couchers.utils import Timestamp_from_datetime, date_to_api, now, parse_date, to_aware_datetime
Expand Down Expand Up @@ -372,9 +373,14 @@ def BanUser(
user = session.execute(select(User).where(username_or_email_or_id(request.user))).scalar_one_or_none()
if not user:
context.abort_with_error_code(grpc.StatusCode.NOT_FOUND, "user_not_found")
# Ensure admin note is logged directly
log_admin_action(session, context, user, "ban", note=request.admin_note, level=AdminActionLevel.high)
disable_push_notifications_for_user(
user_id=user.id,
session=session,
)
if not request.admin_note.strip():
context.abort_with_error_code(grpc.StatusCode.INVALID_ARGUMENT, "admin_note_cant_be_empty")
log_admin_action(session, context, user, "ban", note=request.admin_note, level=AdminActionLevel.high)
user.banned_at = now()
return _user_to_details(session, user)

Expand Down
13 changes: 13 additions & 0 deletions app/backend/src/couchers/servicers/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ def notification_to_pb(user: User, notification: Notification) -> notifications_
)


def disable_push_notifications_for_user(user_id: int, session: Session) -> None:
"""
Disables push notifications for a specific user by updating their subscriptions.
"""
session.execute(
update(PushNotificationSubscription)
.where(PushNotificationSubscription.user_id == user_id)
.where(PushNotificationSubscription.disabled_at > now())
.values(disabled_at=now())
)
session.commit()


class Notifications(notifications_pb2_grpc.NotificationsServicer):
def GetNotificationSettings(
self, request: notifications_pb2.GetNotificationSettingsReq, context: CouchersContext, session: Session
Expand Down
2 changes: 1 addition & 1 deletion app/media/src/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from PIL import Image
from PIL.JpegImagePlugin import JpegImageFile

from media.server import create_app
from media.proto import media_pb2, media_pb2_grpc
from media.server import create_app

DATADIR = Path(__file__).parent / "data"

Expand Down