Skip to content
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

feat: Add block users feature #69

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
78d593c
feat: Migrations and initial db queries
kevinszuchet Jan 24, 2025
b953ed1
Merge branch 'main' into feat/blocks
kevinszuchet Feb 25, 2025
5b94ada
feat: New queries abstractions
kevinszuchet Feb 25, 2025
8c3c926
feat: Initial approach to block, unblock, and get blocked users
kevinszuchet Feb 25, 2025
092a473
fix: Bump protocol and fix tests
kevinszuchet Feb 25, 2025
4faffeb
test: improve tests
kevinszuchet Feb 25, 2025
e01097f
fix: Use new type Profile and rename parsers
kevinszuchet Feb 25, 2025
fccda6d
feat: Blocking filter in mutual friends and friendship requests
kevinszuchet Feb 26, 2025
c738e4d
chore: Remove unused function
kevinszuchet Feb 26, 2025
486a165
feat: Filter blocked users from online friends query
kevinszuchet Feb 26, 2025
2e5f168
feat: Add validation in upsert for blocked friendships
kevinszuchet Feb 26, 2025
2b7b469
feat: Add implementation for GetBlockingStatus
kevinszuchet Mar 3, 2025
6e11ef8
feat: Block / Unblock also impact in the friendship history
kevinszuchet Mar 3, 2025
b3d1966
refactor: Back to FriendProfile
kevinszuchet Mar 3, 2025
4b815cc
refactor: Abstract getProfileInfo
kevinszuchet Mar 3, 2025
d16b31b
feat: Implement block updates
kevinszuchet Mar 4, 2025
a920102
feat: GetFriendshipStatus distinguish between BLOCKED and BLOCKED BY
kevinszuchet Mar 4, 2025
68ccc57
chore: Adapt readme
kevinszuchet Mar 4, 2025
e934f44
Merge branch 'main' into feat/blocks
kevinszuchet Mar 4, 2025
67a9bb9
fix: Return proper blocked at date when getting blocked users
kevinszuchet Mar 5, 2025
290c01a
feat: When block/unblock, send friendship status update
kevinszuchet Mar 5, 2025
a911470
fix: GetFriends only retrieve active friendships
kevinszuchet Mar 5, 2025
2231b4c
fix: Drop table after dropping indexes
kevinszuchet Mar 6, 2025
b7b2965
feat: Return more informative errores on block/unblock
kevinszuchet Mar 6, 2025
25c7b62
fix: Missing block updates handler + should not block/unblock yourself
kevinszuchet Mar 6, 2025
79f6a9c
chore: Reduce noise in the logs
kevinszuchet Mar 6, 2025
30c53c0
fix: Get Mutual Friends query was using incorrect table alias in the …
kevinszuchet Mar 6, 2025
53c50db
fix: Block updates should notify who blocks/unblocks to the blocked/u…
kevinszuchet Mar 6, 2025
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
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ A microservice that handles social interactions (friendships) for Decentraland,
- [🏗 Architecture](#-architecture)
- [Component-Based Architecture](#component-based-architecture)
- [Database Design](#database-design)
- [Flow Diagrams](#flow-diagrams)
- [Friendship Flow Diagrams](#friendship-flow-diagrams)
- [Block System Flow](#block-system-flow)
- [🚀 Getting Started](#-getting-started)
- [Prerequisites](#prerequisites)
- [Local Development](#local-development)
Expand All @@ -27,6 +28,7 @@ A microservice that handles social interactions (friendships) for Decentraland,
- Mutual friends discovery
- Online status tracking
- Integration with Archipelago for peer synchronization
- User blocking system

## 🏗 Architecture

Expand Down Expand Up @@ -63,20 +65,28 @@ erDiagram
jsonb metadata
timestamp timestamp
}
BLOCKS {
uuid id PK
varchar blocker_address
varchar blocked_address
timestamp blocked_at
}

FRIENDSHIPS ||--o{ FRIENDSHIP_ACTIONS : "has"
BLOCKS ||--o{ FRIENDSHIPS : "blocks"
```

The database schema supports:

- Bidirectional friendships
- Action history tracking
- User blocking system
- Metadata for requests
- Optimized queries with proper indexes

See migrations for details: [migrations](./src/migrations)

### Flow Diagrams
### Friendship Flow Diagrams

```mermaid
sequenceDiagram
Expand Down Expand Up @@ -147,6 +157,37 @@ sequenceDiagram
deactivate NATS
```

### Block System Flow

```mermaid
sequenceDiagram
participant Client
participant RPC Server
participant DB
participant Redis
participant PubSub

Note over Client,PubSub: Block User Flow
Client->>RPC Server: Block User Request
RPC Server->>DB: Create Block Record
RPC Server->>DB: Update Friendship Status (if exists)
RPC Server->>PubSub: Publish Block Update
PubSub-->>Client: Block Status Update

Note over Client,PubSub: Unblock User Flow
Client->>RPC Server: Unblock User Request
RPC Server->>DB: Remove Block Record
RPC Server->>PubSub: Publish Unblock Update
PubSub-->>Client: Block Status Update

Note over Client,PubSub: Block Status Updates
Client->>RPC Server: Subscribe to Block Updates
loop Block Updates
PubSub-->>RPC Server: Block Status Change
RPC Server-->>Client: Stream Block Update
end
```

## 🚀 Getting Started

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@aws-sdk/client-sns": "^3.734.0",
"@dcl/platform-crypto-middleware": "^1.1.0",
"@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-13021146556.commit-7327e37.tgz",
"@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-13654029584.commit-3cb93f2.tgz",
"@dcl/rpc": "^1.1.2",
"@dcl/schemas": "^16.0.0",
"@well-known-components/env-config-provider": "^1.2.0",
Expand Down
Loading
Loading