mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.0 KiB
TypeScript
53 lines
1.0 KiB
TypeScript
import { request } from '../api/request';
|
|
|
|
export interface FriendRequest {
|
|
_id: string;
|
|
from: string;
|
|
to: string;
|
|
message: string;
|
|
}
|
|
|
|
/**
|
|
* 发送好友请求
|
|
* @param targetId 目标用户id
|
|
*/
|
|
export async function addFriendRequest(
|
|
targetId: string
|
|
): Promise<FriendRequest> {
|
|
const { data } = await request.post('/api/friend/request/add', {
|
|
to: targetId,
|
|
});
|
|
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
* 同意好友请求
|
|
* @param requestId 好友请求ID
|
|
*/
|
|
export async function acceptFriendRequest(requestId: string): Promise<void> {
|
|
await request.post('/api/friend/request/accept', {
|
|
requestId,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 拒绝好友请求
|
|
* @param requestId 好友请求ID
|
|
*/
|
|
export async function denyFriendRequest(requestId: string): Promise<void> {
|
|
await request.post('/api/friend/request/deny', {
|
|
requestId,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 取消好友请求
|
|
* @param requestId 好友请求ID
|
|
*/
|
|
export async function cancelFriendRequest(requestId: string): Promise<void> {
|
|
await request.post('/api/friend/request/cancel', {
|
|
requestId,
|
|
});
|
|
}
|