Skip to content

BE (Integration) - Social Service Integration (Permission Check) #10

Description

@ImeshGimshan

Social Service Integration (Permission Check)

Description

Connect the Chat Service to the Social Service to verify friendship before allowing messages to be sent.


Features

1. Call Social Service Endpoint

  • Use HTTP module to call the Social Service's friendship check endpoint
  • Send request with sender ID and recipient ID
  • Receive friendship status response

2. Check Friendship Status

  • Before sending a message, verify if sender and recipient are friends
  • Block message if they are not friends
  • Allow message only if status is FRIENDS

3. Error Handling

  • If Social Service is down, show error to user
  • If users are not friends, show error message
  • Display error as a toast notification to sender

What Needs to Happen

When user tries to send a message:

  1. Capture sender ID and recipient ID
  2. Call Social Service API endpoint
  3. Get friendship status response
  4. If FRIENDS → Allow message to be sent
  5. If NOT FRIENDS → Block message and show error toast
  6. If Social Service fails → Show error toast

Error Messages:

  • "You are not friends with this user"
  • "Failed to verify friendship status"
  • "Social Service is currently unavailable"

Acceptance Criteria

  • HTTP module is configured to call Social Service
  • Friendship check happens before message is sent
  • Message is blocked if status is not FRIENDS
  • Message is sent successfully if status is FRIENDS
  • Error toast appears when users are not friends
  • Error toast appears when Social Service fails
  • Sender ID is correctly extracted from authentication
  • Recipient ID is correctly passed from message payload
  • Social Service endpoint URL is configurable
  • HTTP timeout is configured to prevent hanging requests
  • Basic error handling is implemented
  • Feature is tested with valid friendship
  • Feature is tested with invalid friendship
  • Feature is tested with Service unavailability

Dependencies

  • HTTP Module (Axios or similar)
  • Social Service running and accessible
  • Social Service endpoint: GET /internal/status/: user1/:user2

Simple Implementation Flow

User sends message
    ↓
Extract sender & recipient IDs
    ↓
Call Social Service
    ↓
Get response (FRIENDS or NOT FRIENDS)
    ↓
If FRIENDS → Send message ✓
If NOT FRIENDS → Show error toast ✗
If Error → Show error toast ✗

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status
In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions