Some tweaks and comments

This commit is contained in:
Andrew Ferrazzutti 2021-02-20 03:48:08 -05:00
parent eb0f37274c
commit ec081e94df
4 changed files with 13 additions and 7 deletions

View File

@ -73,7 +73,8 @@ async def login_do(evt: CommandEvent, gen: AsyncGenerator[Tuple[str, str], None]
qr_event_id = await evt.az.intent.send_message(evt.room_id, content) qr_event_id = await evt.az.intent.send_message(evt.room_id, content)
elif item[0] == "pin": elif item[0] == "pin":
pin = item[1] pin = item[1]
content = TextMessageEventContent(body=pin, msgtype=MessageType.NOTICE) message = f"Enter this PIN in LINE on your primary device:\n{pin}"
content = TextMessageEventContent(body=message, msgtype=MessageType.NOTICE)
if pin_event_id: if pin_event_id:
content.set_edit(pin_event_id) content.set_edit(pin_event_id)
await evt.az.intent.send_message(evt.room_id, content) await evt.az.intent.send_message(evt.room_id, content)

View File

@ -108,7 +108,7 @@ export default class Client {
} }
sendQRCode(url) { sendQRCode(url) {
this.log("Sending QR", url, "to client") this.log(`Sending QR ${url} to client`)
return this._write({ return this._write({
id: --this.notificationID, id: --this.notificationID,
command: "qr", command: "qr",
@ -126,7 +126,7 @@ export default class Client {
} }
sendFailure(reason) { sendFailure(reason) {
this.log(`Sending failure "${reason}" to client`) this.log(`Sending failure to client${reason ? `: "${reason}"` : ""}`)
return this._write({ return this._write({
id: --this.notificationID, id: --this.notificationID,
command: "failure", command: "failure",

View File

@ -227,6 +227,7 @@ class MautrixController {
*/ */
parseParticipantList(element) { parseParticipantList(element) {
// TODO Slice to exclude first member, which is always yourself (right?) // TODO Slice to exclude first member, which is always yourself (right?)
// TODO Only slice if double-puppeting is enabled!
//return Array.from(element.children).slice(1).map(child => { //return Array.from(element.children).slice(1).map(child => {
return Array.from(element.children).map(child => { return Array.from(element.children).map(child => {
return { return {
@ -444,7 +445,7 @@ class MautrixController {
for (const change of changes) { for (const change of changes) {
for (const node of change.addedNodes) { for (const node of change.addedNodes) {
const emailArea = node.querySelector("#login_email_area") const emailArea = node.querySelector("#login_email_area")
if (emailArea && !emailArea.getAttribute("class").includes("MdNonDisp")) { if (emailArea && !emailArea.classList.contains("MdNonDisp")) {
window.__mautrixSendEmailCredentials() window.__mautrixSendEmailCredentials()
return return
} }
@ -496,7 +497,7 @@ class MautrixController {
} }
const button = element.querySelector("dialog button") const button = element.querySelector("dialog button")
this.expiryObserver = new MutationObserver(changes => { this.expiryObserver = new MutationObserver(changes => {
if (changes.length == 1 && !changes[0].target.getAttribute("class").includes("MdNonDisp")) { if (changes.length == 1 && !changes[0].target.classList.contains("MdNonDisp")) {
window.__mautrixExpiry(button) window.__mautrixExpiry(button)
} }
}) })

View File

@ -434,6 +434,11 @@ export default class MessagesPuppeteer {
let participants let participants
const participantList = await chatDetailArea.$("ul.mdRGT13Ul") const participantList = await chatDetailArea.$("ul.mdRGT13Ul")
if (participantList) { if (participantList) {
// TODO Use "id" syntax to tell if this is a chat/room/group, not selectors:
// c: group
// r: room
// u: chat
// It's defined by the LINE API!
if (await chatDetailArea.$("#leaveGroup")) { if (await chatDetailArea.$("#leaveGroup")) {
this.log("Found group") this.log("Found group")
// This is a *group* (like a Matrix room) // This is a *group* (like a Matrix room)
@ -461,7 +466,6 @@ export default class MessagesPuppeteer {
// TODO Or just look up the member ID in the contact list? // TODO Or just look up the member ID in the contact list?
} }
this.log(`Found participants: ${participants}`)
return { return {
participants, participants,
...await this.page.$eval(this._listItemSelector(id), ...await this.page.$eval(this._listItemSelector(id),
@ -575,7 +579,7 @@ export default class MessagesPuppeteer {
_receivePIN(pin) { _receivePIN(pin) {
if (this.client) { if (this.client) {
this.client.sendPIN(`Your PIN is: ${pin}`).catch(err => this.client.sendPIN(pin).catch(err =>
this.error("Failed to send new PIN to client:", err)) this.error("Failed to send new PIN to client:", err))
} else { } else {
this.log("No client connected, not sending new PIN") this.log("No client connected, not sending new PIN")