feat(core): implement services for issue #8 #26

Merged
shoko merged 2 commits from fix/issue-8 into main 2026-04-03 14:23:33 +02:00
Owner

Summary

Implement pure business logic services in core/services.py.

Services

BountyService

Handles bounty operations in a room (group or DM via room_id):

  • add_bounty() - Add new bounty to room
  • list_bounties() - List all bounties in room
  • get_bounty() - Get specific bounty by ID
  • update_bounty() - Update bounty (creator only, raises PermissionError)
  • delete_bounty() - Delete bounty (creator only, raises PermissionError)

TrackingService

Handles tracking bounty operations:

  • track_bounty() - Start tracking (raises ValueError if bounty not found)
  • untrack_bounty() - Stop tracking
  • get_tracked_bounties() - Get all tracked bounties by user in room

Key Design

  • No Telegram types imported
  • No file I/O (uses storage ports)
  • Timestamps generated at service layer
  • PermissionError for unauthorized operations
  • ValueError for not found (tracking only)

Fixes #8

## Summary Implement pure business logic services in `core/services.py`. ## Services ### BountyService Handles bounty operations in a room (group or DM via room_id): - `add_bounty()` - Add new bounty to room - `list_bounties()` - List all bounties in room - `get_bounty()` - Get specific bounty by ID - `update_bounty()` - Update bounty (creator only, raises PermissionError) - `delete_bounty()` - Delete bounty (creator only, raises PermissionError) ### TrackingService Handles tracking bounty operations: - `track_bounty()` - Start tracking (raises ValueError if bounty not found) - `untrack_bounty()` - Stop tracking - `get_tracked_bounties()` - Get all tracked bounties by user in room ## Key Design - No Telegram types imported - No file I/O (uses storage ports) - Timestamps generated at service layer - PermissionError for unauthorized operations - ValueError for not found (tracking only) Fixes #8
shoko added 1 commit 2026-04-03 11:27:05 +02:00
- Add BountyService for room bounty operations (group and personal)
- Add TrackingService for tracking bounty operations
- Uses RoomStorage and TrackingStorage ports
- PermissionError raised when non-creator edits/deletes
- ValueError raised when bounty not found in tracking
han approved these changes 2026-04-03 13:14:56 +02:00
Dismissed
han left a comment
Collaborator

lgtm

lgtm
han requested changes 2026-04-03 13:16:06 +02:00
Dismissed
han left a comment
Collaborator

don't we need unit tests for this services? in a way to make sure that everything we defined in this service are working as expected even if with faulty input

don't we need unit tests for this services? in a way to make sure that everything we defined in this service are working as expected even if with faulty input
shoko added 1 commit 2026-04-03 13:36:10 +02:00
- Test BountyService: add_bounty, list_bounties, get_bounty, update_bounty, delete_bounty
- Test TrackingService: track_bounty, untrack_bounty, get_tracked_bounties
- Test edge cases: permission errors, not found, duplicate tracking
han approved these changes 2026-04-03 13:50:45 +02:00
han left a comment
Collaborator

lgtm

lgtm
shoko merged commit 2a9795a0c3 into main 2026-04-03 14:23:33 +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#26