fix(export): 生成 tdata 时写入账号 user_id,修复桌面端仍要求登录
- Telethon->tdata 桥接脚本新增 userId 参数并注入 session.self.userId\n- AccountExportService 调用转换时传入当前账号 UserId\n- 避免 @mtcute/convert 默认写入 userId=0 导致 Telegram Desktop 识别为未登录
This commit is contained in:
1 parent
57683f8de8
commit
eec251ab82
2 files changed
+14
-2
No files matched your search
@@ -43,11 +43,21 @@ try {
|
||||
private const string NodeScriptTelethonToTdata = """
|
||||
import { convertFromTelethonSession, convertToTdata } from '@mtcute/convert';
|
||||
|
||||
const telethonSession = process.argv[process.argv.length - 2];
|
||||
const telethonSession = process.argv[process.argv.length - 3];
|
||||
const userIdRaw = process.argv[process.argv.length - 2];
|
||||
const outputDir = process.argv[process.argv.length - 1];
|
||||
|
||||
try {
|
||||
const session = convertFromTelethonSession(telethonSession);
|
||||
const userId = Number.parseInt(userIdRaw, 10);
|
||||
if (Number.isFinite(userId) && userId > 0) {
|
||||
session.self = {
|
||||
userId,
|
||||
isBot: false,
|
||||
isPremium: false,
|
||||
usernames: [],
|
||||
};
|
||||
}
|
||||
await convertToTdata(session, { path: outputDir });
|
||||
console.log(JSON.stringify({ ok: true }));
|
||||
} catch (error) {
|
||||
@@ -141,6 +151,7 @@ try {
|
||||
|
||||
public static async Task<ConvertToTdataResult> TryConvertTelethonStringSessionToTdataAsync(
|
||||
string telethonSessionString,
|
||||
long? userId,
|
||||
string outputTdataDirectory,
|
||||
ILogger logger,
|
||||
CancellationToken cancellationToken = default)
|
||||
@@ -164,7 +175,7 @@ try {
|
||||
|
||||
var run = await RunProcessAsync(
|
||||
fileName: "node",
|
||||
arguments: new[] { "--input-type=module", "-e", NodeScriptTelethonToTdata, "--", normalizedSession, absoluteOutputDir },
|
||||
arguments: new[] { "--input-type=module", "-e", NodeScriptTelethonToTdata, "--", normalizedSession, (userId ?? 0).ToString(), absoluteOutputDir },
|
||||
workingDirectory: RuntimeDir,
|
||||
timeoutMs: ConvertTimeoutMs,
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
@@ -177,6 +177,7 @@ public class AccountExportService
|
||||
|
||||
var tdataResult = await TdataSessionBridge.TryConvertTelethonStringSessionToTdataAsync(
|
||||
telethonSessionString: telethonResult.SessionString,
|
||||
userId: account.UserId > 0 ? account.UserId : null,
|
||||
outputTdataDirectory: tempTdataDir,
|
||||
logger: _logger,
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
Reference in new issue
Block a user