Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
GetMessageListParams,
BaseParams,
NewBaseParams,
GetFollowAndContactListApiParams,
GetGroupMemberListParams,
InviteGroupMemberParams,
JoinGroupParams,
Expand Down Expand Up @@ -218,7 +219,7 @@ export const searchContactRequest = async (payload: SearchParams) => {
});
};

export const getContactListRequest = async (payload: NewCommonGetListParams) => {
export const getFollowAndContactListRequest = async (payload: GetFollowAndContactListApiParams) => {
return await request.get('/api/user_follow_contacts/', {
params: payload,
});
Expand Down
45 changes: 30 additions & 15 deletions src/contact/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { getDataSignature, newDateFormat, transformAddress } from '../utils';
import {
followOperationRequest,
getContactListRequest,
getFollowAndContactListRequest,
getFollowerListRequest,
getFollowingListRequest,
getMyFriendListRequset,
Expand Down Expand Up @@ -59,6 +59,20 @@ export class Contact {
});
return data;
}

async getFollowerAndFollowingList(option: PageParams) {
const { userid, PrivateKey } = this._keys;
const timestamp = Date.now();
const signContent = userid + timestamp;
const web3mq_user_signature = await getDataSignature(PrivateKey, signContent);
const { data } = await getFollowAndContactListRequest({
userid,
web3mq_user_signature,
timestamp,
...option,
});
return data.user_list;
}

async getContactList(option: PageParams): Promise<ContactListItemType[]> {
const { emit } = this._client;
Expand All @@ -68,20 +82,22 @@ export class Contact {
const signContent = userid + timestamp;
const web3mq_user_signature = await getDataSignature(PrivateKey, signContent);

const { data } = await getContactListRequest({
const { data } = await getFollowAndContactListRequest({
userid,
web3mq_user_signature,
timestamp,
follow_status: 'follow_each',
...option,
});
const newContacts = data.user_list.filter((item: ContactListItemType) => item.follow_status === 'follow_each');
if (this.contactList && option.page !== 1) {
this.contactList = [...this.contactList, ...newContacts];
this.contactList = [...this.contactList, ...data.user_list];
} else {
this.contactList = newContacts;
this.contactList = data.user_list;
}
if (this._client.listeners.events['contact.getContactList']) {
emit('contact.getContactList', { type: 'contact.getContactList' });
}
emit('contact.getContactList', { type: 'contact.getContactList' });
return newContacts;
return data.user_list;
}

async getFollowerList(option: PageParams): Promise<ContactListItemType[]> {
Expand Down Expand Up @@ -151,14 +167,13 @@ export class Contact {
const did_pubkey = didType === 'starknet' ? PublicKey : undefined;
const timestamp = Date.now();
let nonce = sha3_224(userid + action + targetUserid + timestamp);
const sign_content = `
Web3MQ wants you to sign in with your ${didType} account:
${address}

For follow signature

Nonce: ${nonce}
Issued At: ${newDateFormat(timestamp, 'Y/m/d h:i')}`;
const sign_content = `Web3MQ wants you to sign in with your ${didType} account:
${address}

For follow signature

Nonce: ${nonce}
Issued At: ${newDateFormat(timestamp, 'Y/m/d h:i')}`;
const { sign: did_signature } = await Client.register.sign(sign_content, address, didType);
const data = await followOperationRequest({
did_pubkey,
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ export interface ProfileParams extends BaseParams {
avatar_url: string;
}

export interface GetFollowAndContactListApiParams extends NewCommonGetListParams {
follow_status?: 'follow_each';
}

export interface SendFriendParams extends BaseParams {
content: string;
target_userid: string;
Expand Down