shdown / luastatus

universal status bar content generator
GNU General Public License v3.0
295 stars 12 forks source link

IMAP plugin not working #64

Closed gsurkov closed 3 years ago

gsurkov commented 3 years ago

First things first, big thanks to luastatus developers and contributors!

The IMAP plugin seems to not work properly with an Outlook account. The log from verbose mode and the source code of the widget are shown below. The log seems to repeat infinitely, with only the aXXXX number incrementing, and the widget's cb() function is never called (even with nil argument).

$ luastatus-i3-wrapper outlook.lua
{"version":1,"click_events":true,"stop_signal":0,"cont_signal":0}
[
>   a0001 LOGIN [redacted]@outlook.com [redacted]
<   * OK The Microsoft Exchange IMAP4 service is ready. [redacted]
<   a0001 OK LOGIN completed.
>   a0002 SELECT Inbox
<   * 2 EXISTS
<   * 0 RECENT
<   * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
<   * OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
<   * OK [UNSEEN 1] Is the first unseen message
<   * OK [UIDVALIDITY 14] UIDVALIDITY value
<   * OK [UIDNEXT 341] The next unique identifier value
<   a0002 OK [READ-WRITE] SELECT completed.
>   a0003 STATUS inbox (UNSEEN)
<   * STATUS Inbox (UNSEEN 2)
<   a0003 OK STATUS completed.
>   a0004 STATUS inbox (UNSEEN)
<   * STATUS Inbox (UNSEEN 2)
<   a0004 OK STATUS completed.
>   a0005 STATUS inbox (UNSEEN)
<   * STATUS Inbox (UNSEEN 2)
<   a0005 OK STATUS completed.
... ad infinitum
credentials = require "credentials"

widget = luastatus.require_plugin("imap").widget {
    verbose = true,
    host = "outlook.office365.com",
    port = 993,
    mailbox = "Inbox",
    use_ssl = true,
    timeout = 2 * 60,
    handshake_timeout = 10,
    login = credentials.outlook.login,
    password = credentials.outlook.password,
    error_sleep_period = 60,

    cb = function(unseen)
        local color_urgent = "#e45649"
        local label = "MAIL:"

        if unseen == nil then
            return nil
        elseif unseen == 0 then
            return { full_text = label .. unseen }
        else
            return { full_text = label .. unseen, color = color_urgent }
        end
    end
}
shdown commented 3 years ago

Thanks for reporting this. Hopefully this is fixed now; please try the latest master version.

gsurkov commented 3 years ago

Works perfectly now, huge thanks for the fix.