Quick forwarding with extra content, with mutt.

Continuing the discussion from Any mutt hackers on here?:

Okay, here is the deal: I want to quickly process my inbox, by creating todos for myself in GitLab.

I have issue creation by email working in GitLab, but there are two things that aren’t working as I want.

First, when an issue is created, it is authored by me, as expected, but nothing else happens. I have a private repo set up, but I also want the issues assigned to me, and to be marked as a todo in GitLab. I can fix that by including a slash command in the message, specifically /assign @maiki.

The second issue I have is that mutt is forwarding in a way that I don’t understand, because I don’t deal with message headers very often. I thought maybe forwarding was broken with GitLab, but I tested with a different email client (Geary) and the forward worked as expected. I will show ya what I mean.

I asked @tim to send me an email, from which to create an issue.

If I forward from mutt, the issue is created like so:

That isn’t great. Here is the forward from Geary:

That is more of what I am looking for. One last thing, in my troubleshooting I learned about “bouncing” a message in mutt. Even though the message ought to be accepted as it is verified by the secret email address that contains a personal token, it still doesn’t accept the message, and instead replies with an error message to the original sender, like so (thanks @tim!):

What I need to know

My ideal scenario is that I tag one or more messages in mutt and then have them become todo issues assigned to me. As I am not adding additional content, it seems like a message bounce is the best practice, except I don’t know of another way to assign it to me sans a slash command.

Therefore, what I need to figure out is modifying the forwarded message so it not only includes the slash command, but also formats the message in a way that is parsed by GitLab.

I fairly certain I can create a macro to add the slash command and bind it to a key, but I can’t quite figure out how to format the forward template in mutt. If I can figure that out, maybe I can get it working the way I want. I included all the moving parts in the case an alternative exists that eludes me. :slight_smile:

Okay, I’ve figured out part of this, using three config variables, $sig_dashes, $sig_on_top and $signature.

These two lines are from my .muttrc:

send-hook . "set signature=''"
send-hook "~t @allthe.codes" "set sig_dashes=no; set sig_on_top=yes; set signature='~/.mutt/gitlab'"

The first line is the default, and as I don’t use signatures for anything else I only need to point to a non-existent signature file. If I am sending a message to an address matching @allthe.codes, it removes the -- before the signature, and takes the contents of ~/.mutt/gitlab and appends it at the top of the message, via sig_on_top; I should note that putting a regular signature at the top is lame, and I am only doing it here so I can be lazy and not call an external script to process the message.

The contents of ~/.mutt/gitlab is simple:

 
/assign @maiki

Note the first line is empty. So when I go to forward a message, I get something like:

 
/assign @maiki
----- Forwarded message from Tim H <tim@hithlonde.com> -----

> Date: Thu, 18 May 2017 16:42:51 -0700
> From: Tim H <tim@hithlonde.com>
> To: マイキ <maiki@interi.org>
> Subject: The thing?
>
> How is the widget coming along? I need that widget!
>
> Thanks,
>
> Tim H

----- End forwarded message -----

That makes it faster, although everything beneath the “----- Forwarded message from … -----” is being omitted, and I haven’t figured out where that is happening yet. There are a lot of open “reply by email” issues right now, so after I mess with this a bit more, I will see what I can work out on the GitLab side.