feat: implement service layer for Phase 2 #58

Merged
shoko merged 1 commits from fix/issue-43 into main 2026-04-04 07:36:10 +02:00
Owner

Summary

Implements service layer methods for Phase 2 features as specified in issue #43.

BountyService Changes

Admin Management:

  • is_admin(room_id, user_id) - Check if user is admin
  • add_admin(room_id, user_id) - Add admin (requires admin permission)
  • remove_admin(room_id, user_id) - Remove admin (requires admin permission)
  • list_admins(room_id) - List all admin IDs

Timezone:

  • set_timezone(room_id, timezone) - Set room timezone (requires admin)
  • get_timezone(room_id) - Get room timezone (default UTC+0)

Link Uniqueness:

  • check_link_unique(room_id, link, exclude_bounty_id) - Check if link is unique

Modified Methods:

  • add_bounty() - Now requires admin permission and checks link uniqueness
  • update_bounty() - Changed from creator-only to admin-only permission
  • delete_bounty() - Now performs soft delete (sets deleted_at) instead of hard delete
  • get_bounty() - Now filters out soft-deleted bounties
  • list_bounties() - Uses storage method which excludes soft-deleted

New Methods:

  • list_deleted_bounties(room_id) - List soft-deleted bounties (for /recover)

TrackingService Changes

  • get_tracked_bounties() - Now filters out soft-deleted bounties

Permissions (per issue #43)

  • /add, /edit, /delete: admin only (not creator-only as before)
  • /admin, /admin add, /admin remove: admin only
  • /bounty, /show, /track, /untrack, /my: everyone

Tests

All 94 tests pass. Tests updated to reflect new admin-only permissions and soft delete behavior.

Fixes #43

## Summary Implements service layer methods for Phase 2 features as specified in issue #43. ### BountyService Changes **Admin Management:** - `is_admin(room_id, user_id)` - Check if user is admin - `add_admin(room_id, user_id)` - Add admin (requires admin permission) - `remove_admin(room_id, user_id)` - Remove admin (requires admin permission) - `list_admins(room_id)` - List all admin IDs **Timezone:** - `set_timezone(room_id, timezone)` - Set room timezone (requires admin) - `get_timezone(room_id)` - Get room timezone (default UTC+0) **Link Uniqueness:** - `check_link_unique(room_id, link, exclude_bounty_id)` - Check if link is unique **Modified Methods:** - `add_bounty()` - Now requires admin permission and checks link uniqueness - `update_bounty()` - Changed from creator-only to admin-only permission - `delete_bounty()` - Now performs soft delete (sets `deleted_at`) instead of hard delete - `get_bounty()` - Now filters out soft-deleted bounties - `list_bounties()` - Uses storage method which excludes soft-deleted **New Methods:** - `list_deleted_bounties(room_id)` - List soft-deleted bounties (for /recover) ### TrackingService Changes - `get_tracked_bounties()` - Now filters out soft-deleted bounties ### Permissions (per issue #43) - /add, /edit, /delete: admin only (not creator-only as before) - /admin, /admin add, /admin remove: admin only - /bounty, /show, /track, /untrack, /my: everyone ### Tests All 94 tests pass. Tests updated to reflect new admin-only permissions and soft delete behavior. Fixes #43
shoko added 1 commit 2026-04-04 07:27:55 +02:00
BountyService:
- Add is_admin(), add_admin(), remove_admin(), list_admins()
- Add set_timezone(), get_timezone()
- Add check_link_unique(), list_deleted_bounties()
- Modify add_bounty() to check link uniqueness and require admin
- Modify update_bounty() to require admin permission (not creator)
- Modify delete_bounty() to perform soft delete (set deleted_at)
- get_bounty() now filters out soft-deleted bounties
- list_bounties() uses storage.list_bounties() which excludes soft-deleted

TrackingService:
- get_tracked_bounties() now filters out soft-deleted bounties

Tests updated to reflect new admin-only permissions and soft delete behavior.
han approved these changes 2026-04-04 07:35:42 +02:00
han left a comment
Collaborator

lgtm

lgtm
shoko merged commit 42ed551554 into main 2026-04-04 07:36:10 +02:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/jigaido#58