zalo-agent-cli 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/profile.js +19 -3
package/package.json
CHANGED
package/src/commands/profile.js
CHANGED
|
@@ -102,8 +102,18 @@ export function registerProfileCommands(program) {
|
|
|
102
102
|
const bio = result?.profile?.status || "(empty)";
|
|
103
103
|
output({ bio }, program.opts().json, () => info(`Bio: ${bio}`));
|
|
104
104
|
} else {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
await getApi().updateProfileBio(text);
|
|
106
|
+
// Verify by reading back (Zalo may cache, so check)
|
|
107
|
+
const verify = await getApi().fetchAccountInfo();
|
|
108
|
+
const newBio = verify?.profile?.status || "";
|
|
109
|
+
if (newBio === text) {
|
|
110
|
+
output({ bio: newBio }, program.opts().json, () => success(`Bio updated to: "${text}"`));
|
|
111
|
+
} else {
|
|
112
|
+
output({ bio: newBio, requested: text }, program.opts().json, () => {
|
|
113
|
+
success(`Bio update request sent: "${text}"`);
|
|
114
|
+
info("Note: Zalo may take time to reflect changes, or bio may not be supported for your account type.");
|
|
115
|
+
});
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
} catch (e) {
|
|
109
119
|
error(`Bio update failed: ${e.message}`);
|
|
@@ -125,10 +135,16 @@ export function registerProfileCommands(program) {
|
|
|
125
135
|
// Fetch current profile to fill missing fields (API requires all 3)
|
|
126
136
|
const current = await getApi().fetchAccountInfo();
|
|
127
137
|
const p = current?.profile || {};
|
|
138
|
+
// Convert sdob (DD/MM/YYYY) to YYYY-MM-DD format required by API
|
|
139
|
+
let currentDob = "2000-01-01";
|
|
140
|
+
if (p.sdob) {
|
|
141
|
+
const parts = p.sdob.split("/");
|
|
142
|
+
if (parts.length === 3) currentDob = `${parts[2]}-${parts[1]}-${parts[0]}`;
|
|
143
|
+
}
|
|
128
144
|
const payload = {
|
|
129
145
|
profile: {
|
|
130
146
|
name: opts.name || p.displayName || p.zaloName,
|
|
131
|
-
dob: opts.dob ||
|
|
147
|
+
dob: opts.dob || currentDob,
|
|
132
148
|
gender: opts.gender !== undefined ? Number(opts.gender) : p.gender ?? 0,
|
|
133
149
|
},
|
|
134
150
|
};
|