Skip to content

pipe_to() and move_messages() on same results #308

@Feli-xyz

Description

@Feli-xyz

Doing some improvements to my config I'm stuck now. If it's not a bug any help will be welcome.

This works as expected

function pipe_code(mbox)
  selection =
      mbox.INBOX:contain_body('magic: ')

  selection:move_messages(mbox['INBOX/code'])
end
imapfilter: IMAP (3): 1098 NO [TRYCREATE] Mailbox doesn't exist: INBOX/code (0.001 + 0.000 secs).
1 messages moved from example@example.com@mailserver.com/INBOX to example@example.com@mailserver.com/INBOX/code.

and also does

function pipe_code(mbox)

  selection =
      mbox.INBOX:contain_body('magic: ')

  results = Set {}

  for _, mesg in ipairs(selection) do
      mbox, uid = table.unpack(mesg)
      from = mbox[uid]:fetch_field('From')
      from=string.match(from,'.*From:.*%<(.*)%>')
      body = mbox[uid]:fetch_body()
      code=string.match(body,'.*magic: (%d%d%d%d)')
		
      pipe_to('/var/local/imapfilter/test.sh', code .. '\n')

      table.insert(results, {mbox, uid})

  end

  results:delete_messages()
end
Fetched field "From" of example@example.com@mailserver.com/INBOX[36485].
Fetched the body of example@example.com@mailserver.com/INBOX[36485].

1 messages deleted in example@example.com@mailserver.com/INBOX.

but I can't find a solution for

--  results:delete_messages()
    results:move_messages(mbox['INBOX/code'])
Fetched field "From" of example@example.com@mailserver.com/INBOX[36486].
Fetched the body of example@example.com@mailserver.com/INBOX[36486].

imapfilter: /usr/local/share/imapfilter/mailbox.lua:186: bad argument #3 to 'copy' (string expected, got table)
stack traceback:
        [C]: in ?
        [C]: in field 'copy'
        /usr/local/share/imapfilter/mailbox.lua:186: in field '_copy_messages'
        /usr/local/share/imapfilter/mailbox.lua:724: in field 'move_messages'
        /usr/local/share/imapfilter/set.lua:230: in method 'move_messages'
        config-code.lua:58: in function 'pipe_code'
        config-code.lua:107: in main chunk

Versions:

imapfilter -V; lua -v
IMAPFilter 2.8.3  
Lua 5.4.8 

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions