opencode-copilot-account-switcher 0.14.4 → 0.14.5
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/dist/wechat/bind-flow.js +16 -13
- package/package.json +1 -1
package/dist/wechat/bind-flow.js
CHANGED
|
@@ -84,21 +84,11 @@ export async function runWechatBindFlow(input) {
|
|
|
84
84
|
}
|
|
85
85
|
const boundAt = now();
|
|
86
86
|
const userIdFromWait = pickFirstNonEmptyString(waited?.userId, waited?.openid, waited?.uid);
|
|
87
|
-
const operatorBinding = {
|
|
88
|
-
wechatAccountId: accountId,
|
|
89
|
-
userId: "",
|
|
90
|
-
boundAt,
|
|
91
|
-
};
|
|
92
87
|
const previousOperatorBinding = input.action === "wechat-rebind" ? await loadOperatorBinding() : undefined;
|
|
93
88
|
let menuAccount;
|
|
94
89
|
let boundUserId = "";
|
|
90
|
+
let shouldRollbackBinding = false;
|
|
95
91
|
try {
|
|
96
|
-
if (input.action === "wechat-rebind") {
|
|
97
|
-
await persistOperatorRebinding(operatorBinding);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
await persistOperatorBinding(operatorBinding);
|
|
101
|
-
}
|
|
102
92
|
const menuAccountState = accountId
|
|
103
93
|
? {
|
|
104
94
|
...(helpers.latestAccountState ?? {
|
|
@@ -120,7 +110,18 @@ export async function runWechatBindFlow(input) {
|
|
|
120
110
|
throw new Error("missing userId after qr login");
|
|
121
111
|
}
|
|
122
112
|
boundUserId = userId;
|
|
123
|
-
operatorBinding
|
|
113
|
+
const operatorBinding = {
|
|
114
|
+
wechatAccountId: accountId,
|
|
115
|
+
userId,
|
|
116
|
+
boundAt,
|
|
117
|
+
};
|
|
118
|
+
shouldRollbackBinding = true;
|
|
119
|
+
if (input.action === "wechat-rebind") {
|
|
120
|
+
await persistOperatorRebinding(operatorBinding);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
await persistOperatorBinding(operatorBinding);
|
|
124
|
+
}
|
|
124
125
|
const settings = await input.readCommonSettings();
|
|
125
126
|
const notifications = settings.wechat?.notifications ?? {
|
|
126
127
|
enabled: true,
|
|
@@ -143,7 +144,9 @@ export async function runWechatBindFlow(input) {
|
|
|
143
144
|
await input.writeCommonSettings(settings);
|
|
144
145
|
}
|
|
145
146
|
catch (error) {
|
|
146
|
-
|
|
147
|
+
if (shouldRollbackBinding) {
|
|
148
|
+
await rollbackBinding(input.action, previousOperatorBinding, persistOperatorRebinding, clearOperatorBinding);
|
|
149
|
+
}
|
|
147
150
|
throw error;
|
|
148
151
|
}
|
|
149
152
|
return {
|