Commit 35d3a47f by Sixong.Zhu

cs

parent fee0ea0d
Showing with 13 additions and 10 deletions
import { UniplatSdk } from "uniplat-sdk";
import Chat from "../xim"; import Chat from "../xim";
export type UserMapping = { export type UserMapping = {
...@@ -12,22 +13,24 @@ const userMapping: UserMapping = {}; ...@@ -12,22 +13,24 @@ const userMapping: UserMapping = {};
export const getUserMapping = () => userMapping; export const getUserMapping = () => userMapping;
export async function getUserInfo(eid: string) { export async function getUserInfo(eid: string, sdk?: UniplatSdk) {
if (userMapping[eid]) { if (userMapping[eid]) {
return userMapping[eid]; return userMapping[eid];
} }
if (!+eid) { if (!+eid) {
return { name: '', phone: '', icon: '' }; return { name: '', phone: '', icon: '' };
} }
const info = await Chat.getSdk().domainService('passport', 'anonymous', `oidc.account/user_info?id=${eid}`).request<any, any, { const info = await (sdk || Chat.getSdk())
avatar_url: string; .domainService('passport', 'anonymous', `oidc.account/user_info?id=${eid}`)
email: string; .request<any, any, {
id: string; avatar_url: string;
mobile: string; email: string;
realname: string; id: string;
uniplatId: string; mobile: string;
username: string; realname: string;
}>('get'); uniplatId: string;
username: string;
}>('get');
const data = { const data = {
name: info.username || info.realname || info.mobile || info.mobile, name: info.username || info.realname || info.mobile || info.mobile,
phone: info.mobile, phone: info.mobile,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment