DevByte-Community / DevByte-Community/Community-API-Backend

Add Social Contacts Feature to User Profiles

未关闭
#75 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
good first issue
主要语言
JavaScript
星标
2
派生
11
PR 合并指标
30 天内没有已合并 PR

描述

Ticket ID: USER-CONTACTS-001
Priority: Medium

**Feature Description**

Add social media/contact links (GitHub, LinkedIn, Twitter, etc.) to user profiles using a JSONB column in the users table. Enable users to manage their public contact information and display it in community exploration pages.

**Acceptance Criteria**

1. Database Migration
```
sql

-- Add JSONB column to users table
ALTER TABLE users
ADD COLUMN contacts JSONB DEFAULT '[]'::jsonb,
ADD COLUMN bio TEXT DEFAULT '',
ADD COLUMN location VARCHAR(100) DEFAULT '';

-- Create index for efficient querying
CREATE INDEX idx_users_contacts ON users USING gin(contacts);
```

2. Contact Schema Structure

- Each contact in the JSONB array must follow this structure:
```
json

{
"platform": "github",
"url": "https://github.com/username"
}

Supported Platforms:

github, linkedin, twitter, portfolio, website

discord, behance, dribbble, medium, youtube

instagram, facebook, stackoverflow, devto
```

3. Updated Endpoints
`GET /api/v1/users/:id/profile`

- Include contacts, bio, location in response

- Filter contacts: only show isPublic: true for non-owner viewers

`PATCH /api/v1/users/profile (Enhanced)`

- Extend existing endpoint to handle:

- contacts array validation and update

- bio field (max 500 characters)

- location field (max 100 characters)

4. Validation Rules

- Contacts Array:

- Must be an array (max 10 items)

- Each contact must have platform and url

- platform must be from supported list

- url must be valid URL format

- Bio: Max 500 characters, optional

- Location: Max 100 characters, optional

5. Response Format

User Profile Response:
```
json

{
"success": true,
"message": "User profile retrieved successfully",
"user": {
"id": "uuid",
"fullName": "Aisha Patel",
"bio": "Crafting pixel-perfect interfaces...",
"location": "Lagos, Nigeria",
"profilePicture": "url",
"contacts": [
{
"platform": "github",
"url": "https://github.com/aishapatel",
"username": "aishapatel",
"isPublic": true
}
],
"stats": {
"projects": 11,
"contributions": 178,
"joinedDate": "May 2023"
}
}
}
```

6. Testing

- Unit tests for contact validation

- Integration tests for profile endpoints

- Test maximum array size enforcement

7. Documentation Updates

Update Swagger/OpenAPI documentation

🚀 Success Metrics

All existing users automatically have empty contacts array

Profile pages load with contacts in < 200ms

Contact updates succeed with proper validation

贡献指南

打开贡献指南

调研方向

首先定位 users 表以及现有的 GET /api/v1/users/:id/profile 和 PATCH /api/v1/users/profile 处理器,然后检查它们的验证和响应测试。在实现 migration、验证、可见性规则和响应字段之前,检查 Swagger/OpenAPI 文档以及现有的 profile 行为。完成的标准是:列出的单元测试和集成测试覆盖限制和过滤,现有用户的 contacts 为空,并且 API 文档已更新。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, sql
领域
api, backend, database, documentation, testing
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。