Handle updatesTooLong properly
This commit is contained in:
+1
-1
@@ -136,7 +136,7 @@ class MautrixTelegram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
warn(...message) {
|
warn(...message) {
|
||||||
console.error(chalk.orange(...message))
|
console.error(chalk.yellow(...message))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -226,7 +226,7 @@ class Portal {
|
|||||||
// We don't care about user deletions on chats without portals
|
// We don't care about user deletions on chats without portals
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.app.debug("yellow", "Service message received, creating room for", evt.to.id)
|
this.app.debug("magenta", "Service message received, creating room for", evt.to.id)
|
||||||
await this.createMatrixRoom(evt.source, { invite: [evt.source.matrixUser.userID] })
|
await this.createMatrixRoom(evt.source, { invite: [evt.source.matrixUser.userID] })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-3
@@ -410,14 +410,26 @@ class TelegramPuppet {
|
|||||||
this.app.warn("updatesTooLong received, but we don't have a persistent timestamp :(")
|
this.app.warn("updatesTooLong received, but we don't have a persistent timestamp :(")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
this.app.debug("yellow", "Handling updatesTooLong", this.pts, this.date)
|
this.app.debug("magenta", "Handling updatesTooLong", this.pts, this.date)
|
||||||
const dat = await this.client("updates.getDifference", {
|
const dat = await this.client("updates.getDifference", {
|
||||||
pts: this.pts,
|
pts: this.pts,
|
||||||
date: this.date,
|
date: this.date,
|
||||||
qts: -1,
|
qts: -1,
|
||||||
})
|
})
|
||||||
this.app.debug("yellow", `updatesTooLong data: ${JSON.stringify(dat, "", " ")}`)
|
this.app.debug("magenta", `updates.getDifference: ${JSON.stringify(dat, "", " ")}`)
|
||||||
// TODO use updatesTooLong data?
|
// TODO use dat.users and dat.chats
|
||||||
|
this.pts = dat.state.pts
|
||||||
|
this.date = dat.state.date
|
||||||
|
for (const message of dat.new_messages) {
|
||||||
|
this.onUpdate({
|
||||||
|
_: "updateNewMessage",
|
||||||
|
pts: this.pts,
|
||||||
|
message,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for (const update of dat.other_updates) {
|
||||||
|
this.onUpdate(update)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
this.app.warn("Unrecognized update type:", data._)
|
this.app.warn("Unrecognized update type:", data._)
|
||||||
@@ -437,6 +449,8 @@ class TelegramPuppet {
|
|||||||
//console.log(statusUpdate)
|
//console.log(statusUpdate)
|
||||||
this.app.info("Fetching initial state...")
|
this.app.info("Fetching initial state...")
|
||||||
const state = await this.client("updates.getState", {})
|
const state = await this.client("updates.getState", {})
|
||||||
|
this.pts = state.pts
|
||||||
|
this.date = state.date
|
||||||
this.app.debug("green", "Initial state:", JSON.stringify(state, "", " "))
|
this.app.debug("green", "Initial state:", JSON.stringify(state, "", " "))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error getting initial state:", err)
|
console.error("Error getting initial state:", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user