Refactor user service changeAccountInfo function.
This commit is contained in:
parent
563bd20cfe
commit
da6dc6a296
@ -176,7 +176,7 @@ export class TransactionService {
|
|||||||
const hash = hashFunction.digest();
|
const hash = hashFunction.digest();
|
||||||
const methodSignature = hash.toString('hex').substring(0, 8);
|
const methodSignature = hash.toString('hex').substring(0, 8);
|
||||||
const abiCoder = new utils.AbiCoder();
|
const abiCoder = new utils.AbiCoder();
|
||||||
const abi = await abiCoder.encode(
|
const abi = abiCoder.encode(
|
||||||
['address', 'address', 'address', 'uint256'],
|
['address', 'address', 'address', 'uint256'],
|
||||||
[senderAddress, recipientAddress, tokenAddress, value]
|
[senderAddress, recipientAddress, tokenAddress, value]
|
||||||
);
|
);
|
||||||
|
@ -83,47 +83,18 @@ export class UserService {
|
|||||||
locationType: string,
|
locationType: string,
|
||||||
oldPhoneNumber: string
|
oldPhoneNumber: string
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const accountInfo: any = {
|
const accountInfo = await this.loadChangesToAccountStructure(
|
||||||
vcard: {
|
name,
|
||||||
fn: [{}],
|
phoneNumber,
|
||||||
n: [{}],
|
age,
|
||||||
tel: [{}],
|
type,
|
||||||
},
|
bio,
|
||||||
location: {},
|
gender,
|
||||||
};
|
businessCategory,
|
||||||
if (name) {
|
userLocation,
|
||||||
accountInfo.vcard.fn[0].value = name;
|
location,
|
||||||
accountInfo.vcard.n[0].value = name.split(' ');
|
locationType
|
||||||
}
|
);
|
||||||
if (phoneNumber) {
|
|
||||||
accountInfo.vcard.tel[0].value = phoneNumber;
|
|
||||||
}
|
|
||||||
if (bio) {
|
|
||||||
accountInfo.products = [bio];
|
|
||||||
}
|
|
||||||
if (gender) {
|
|
||||||
accountInfo.gender = gender;
|
|
||||||
}
|
|
||||||
if (age) {
|
|
||||||
accountInfo.age = age;
|
|
||||||
}
|
|
||||||
if (type) {
|
|
||||||
accountInfo.type = type;
|
|
||||||
}
|
|
||||||
if (businessCategory) {
|
|
||||||
accountInfo.category = businessCategory;
|
|
||||||
}
|
|
||||||
if (location) {
|
|
||||||
accountInfo.location.area = location;
|
|
||||||
}
|
|
||||||
if (userLocation) {
|
|
||||||
accountInfo.location.area_name = userLocation;
|
|
||||||
}
|
|
||||||
if (locationType) {
|
|
||||||
accountInfo.location.area_type = locationType;
|
|
||||||
}
|
|
||||||
await vcardValidation(accountInfo.vcard);
|
|
||||||
accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard));
|
|
||||||
const accountKey: string = await User.toKey(address);
|
const accountKey: string = await User.toKey(address);
|
||||||
this.getAccountDetailsFromMeta(accountKey)
|
this.getAccountDetailsFromMeta(accountKey)
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
@ -357,4 +328,60 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
this.accountsList.next(this.accounts);
|
this.accountsList.next(this.accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async loadChangesToAccountStructure(
|
||||||
|
name: string,
|
||||||
|
phoneNumber: string,
|
||||||
|
age: string,
|
||||||
|
type: string,
|
||||||
|
bio: string,
|
||||||
|
gender: string,
|
||||||
|
businessCategory: string,
|
||||||
|
userLocation: string,
|
||||||
|
location: string,
|
||||||
|
locationType: string
|
||||||
|
): Promise<AccountDetails> {
|
||||||
|
const accountInfo: any = {
|
||||||
|
vcard: {
|
||||||
|
fn: [{}],
|
||||||
|
n: [{}],
|
||||||
|
tel: [{}],
|
||||||
|
},
|
||||||
|
location: {},
|
||||||
|
};
|
||||||
|
if (name) {
|
||||||
|
accountInfo.vcard.fn[0].value = name;
|
||||||
|
accountInfo.vcard.n[0].value = name.split(' ');
|
||||||
|
}
|
||||||
|
if (phoneNumber) {
|
||||||
|
accountInfo.vcard.tel[0].value = phoneNumber;
|
||||||
|
}
|
||||||
|
if (bio) {
|
||||||
|
accountInfo.products = [bio];
|
||||||
|
}
|
||||||
|
if (gender) {
|
||||||
|
accountInfo.gender = gender;
|
||||||
|
}
|
||||||
|
if (age) {
|
||||||
|
accountInfo.age = age;
|
||||||
|
}
|
||||||
|
if (type) {
|
||||||
|
accountInfo.type = type;
|
||||||
|
}
|
||||||
|
if (businessCategory) {
|
||||||
|
accountInfo.category = businessCategory;
|
||||||
|
}
|
||||||
|
if (location) {
|
||||||
|
accountInfo.location.area = location;
|
||||||
|
}
|
||||||
|
if (userLocation) {
|
||||||
|
accountInfo.location.area_name = userLocation;
|
||||||
|
}
|
||||||
|
if (locationType) {
|
||||||
|
accountInfo.location.area_type = locationType;
|
||||||
|
}
|
||||||
|
await vcardValidation(accountInfo.vcard);
|
||||||
|
accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard));
|
||||||
|
return accountInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user