Skip to content

Commit

Permalink
fix: getHost
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Dec 23, 2022
1 parent 822b9e5 commit b25d180
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 108 deletions.
5 changes: 4 additions & 1 deletion src/webpack/assets/functions/get-host.js
Expand Up @@ -6,10 +6,13 @@ export async function getHost() {
if (fromwWid) {
const idUser = await API.sendExist(fromwWid._serialized);
if (idUser && idUser.status !== 404) {
const infoUser = await Store.MyStatus.getStatus(idUser);
const infoUser = await Store.Contacts.ContactCollection.get(
fromwWid?._serialized
);
if (infoUser) {
return await API.serializeMeObj(infoUser);
}
}
}
return {};
}
5 changes: 5 additions & 0 deletions src/webpack/assets/help/filter-object.js
Expand Up @@ -116,4 +116,9 @@ export const filterObjects = [{
when: (module) =>
module.sendSetPicture && module.requestDeletePicture ? module : null,
},
{
type: 'Contacts',
when: (module) =>
module.ContactCollection ? module : null,
}
];
114 changes: 12 additions & 102 deletions src/webpack/assets/serializers/serielize-me.js
Expand Up @@ -3,110 +3,20 @@ export const serializeMeObj = async (obj) => {
return null;
}

const connection =
window.Store &&
window.Store.State &&
window.Store.State.Socket &&
window.Store.State.Socket.state
? window.Store.State.Socket.state
: undefined;

let PicThumb = undefined;
if (
obj &&
obj.id &&
obj.id.contact &&
!obj.id.contact.profilePicThumb &&
obj.id.id
) {
PicThumb = await window.Store.ProfilePicThumb.get(obj.id.id._serialized);
}

const newObj = {};
if (!obj.id) {
return newObj;
}


Object.assign(newObj, {
id: obj.id.id ? obj.id.id : null,
email: obj.id.email ? obj.id.email : null,
description: obj.id.description ? obj.id.description : null,
statusConnection: connection,
businessHours: {
timezone:
obj.id.businessHours && obj.id.businessHours.timezone
? obj.id.businessHours.timezone
: null,
},
pushname:
obj.id.contact && obj.id.contact.pushname
? obj.id.contact.pushname
: null,
website: obj.id.website ? obj.id.website : null,
formattedTitle: obj.id.formattedTitle ? obj.id.formattedTitle : null,
categories: obj.id.categories ? obj.id.categories : null,
displayName:
obj.id.contact && obj.id.contact.displayName
? obj.id.contact.displayName
: null,
isBusiness:
obj.id.contact && obj.id.contact.isBusiness
? obj.id.contact.isBusiness
: null,
imgUrl:
obj.id.contact &&
obj.id.contact.profilePicThumb &&
obj.id.contact.profilePicThumb.eurl
? obj.id.contact.profilePicThumb.eurl
: PicThumb && PicThumb.eurl
? PicThumb.eurl
: null,
imgFull:
obj.id.contact &&
obj.id.contact.profilePicThumb &&
obj.id.contact.profilePicThumb.imgFull
? obj.id.contact.profilePicThumb.imgFull
: PicThumb && PicThumb.imgFull
? PicThumb.imgFull
: null,
previewEurl:
obj.id.contact &&
obj.id.contact.profilePicThumb &&
obj.id.contact.profilePicThumb.previewEurl
? obj.id.contact.profilePicThumb.previewEurl
: PicThumb && PicThumb.imgs
? PicThumb.imgs
: null,
id: obj.id ? obj.id : null,
displayName: obj.displayName ? obj.displayName : null,
verifiedName: obj.verifiedName ? obj.verifiedName : null,
searchName: obj.searchName ? obj.searchName : null,
pushname: obj.pushname ? obj.pushname : null,
notifyName: obj.notifyName ? obj.notifyName : null,
isBusiness: obj.isBusiness ? obj.isBusiness : null,
formattedUser: obj.formattedUser ? obj.formattedUser : null,
eurl: obj.profilePicThumb.attributes.eurl ? obj.profilePicThumb.attributes.eurl : null,
...obj.profilePicThumb.attributes,
...obj.businessProfile.attributes,
});
const conn = Store.Me ? Store.Me : undefined;
if (conn && conn.wid && conn.wid._serialized) {
if (
newObj.id &&
newObj.id._serialized &&
conn.wid &&
conn.wid._serialized &&
newObj.id._serialized === conn.wid._serialized &&
conn.phone
) {
Object.assign(newObj, {
binVersion: conn.binVersion ? conn.binVersion : null,
allLocales: conn.allLocales ? conn.allLocales : null,
battery: conn.battery ? conn.battery : null,
phone: {
device_manufacturer: conn.phone.device_manufacturer
? conn.phone.device_manufacturer
: null,
device_model: conn.phone.device_model
? conn.phone.device_model
: null,
os_build_number: conn.phone.os_build_number
? conn.phone.os_build_number
: null,
os_version: conn.phone.os_version ? conn.phone.os_version : null,
wa_version: conn.phone.wa_version ? conn.phone.wa_version : null,
},
});
}
}
return newObj;
};
40 changes: 35 additions & 5 deletions src/webpack/model/interface/host.ts
Expand Up @@ -2,23 +2,53 @@ import { id } from './index';

export interface InterfaceHost {
id: id;
address: string;
coverPhoto: string;
customUrlPath: string;
customUrlPaths: string;
businessHours: businessHours;
eurl: string;
fbPage: object;
eurlStale: boolean;
formattedUser: string;
directConnection: string;
email: string;
description: string;
statusConnection: string;
businessHours: businessHours;
pushname: string;
website: string[];
formattedTitle: string;
categories: categories;
categories: categories[];
displayName: string;
isBusiness: boolean;
imgUrl: string;
imgFull: string;
previewEurl: string;
igProfessional: object;
isProfileLinked: boolean;
latitude: string;
legalEntityDetails: string;
longitude: string;
notifyName: string;
pendingPic: string;
profileOptions: profileOptions
raw: string;
searchName: string;
stale: boolean;
structuredAddress: string;
tag: string;
timestamp: number;
verifiedName: string;
website: string[];
}

interface profileOptions{
cartEnabled: boolean;
commerceExperience: string;
directConnection: string;
}

interface businessHours {
timezone: string;
config: object[];
catalogStatus: string;
}

interface categories {
Expand Down

0 comments on commit b25d180

Please sign in to comment.