I'm keeping this task parallel with T324; whichever is solved first will be the way to go ;-)
Wikibugs-l now also serves Phab e-mails, and they are received in good order at the wikibugs account. This is the format Phab uses:
```
Date: Mon, 6 Oct 2014 18:55:01 +0000
From: mmodell <noreply@phabricator.wikimedia.org>
Subject: [Maniphest] T453: Have phabricator send emails to wikibugs-l list for all task updates
Thread-Topic: T453: Have phabricator send emails to wikibugs-l list for all task updates
X-Herald-Rules: none, <1>, <2>
X-Phabricator-Projects: <#bugzilla-migration>
X-Phabricator-To: <PHID-USER-fn7qnpccfbitivgtw2rt>
X-Phabricator-Cc: <PHID-USER-hgn5uw2jafgjgfvxibhh>
X-Phabricator-Cc: <PHID-USER-fn7qnpccfbitivgtw2rt>
X-Phabricator-Cc: <PHID-USER-lluzkul4z7us4sxkayss>
X-Phabricator-Cc: <PHID-USER-3neel27i7dyu62jbbx2l>
X-Phabricator-Cc: <PHID-USER-z3l4i7dl52qicxtephy5>
X-Phabricator-Cc: <PHID-USER-v7vgzvvcw7v2umf737ri>
X-Phabricator-Cc: <PHID-USER-wil4b5lylrvf3krixlkl>
X-Phabricator-Cc: <PHID-USER-766idcqt4jkngnnuhnrj>
X-Phabricator-Cc: <PHID-USER-muirnivxp5hzppn2a3z7>
X-Phabricator-Cc: <PHID-USER-7ey733eainlhx5xqp4d3>
X-Phabricator-Sent-This-Message: Yes
X-Phabricator-Mail-Tags: <maniphest-status>, <maniphest-comment>
mmodell closed this task as "Resolved".
mmodell added a comment.
Done. The list is getting mail from maniphest, see here: https://www.mail-archive.com/wikibugs-l@lists.wikimedia.org/msg433371.html
TASK DETAIL
https://phabricator.wikimedia.org/T453
REPLY HANDLER ACTIONS
Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: mmodell
Cc: Aklapper, mmodell, Qgil, chasemp, greg, Legoktm, Elitre, Eloquence, valhallasw, jeremyb
```
Of course, these mails are not parsed correctly, and the parser raises an Exception.
There are two possible routes to implement this;
1) parse phab e-mails in the same intermediate format we use for bugzilla:
```
{'Date': 'Tue, 07 Oct 2014 19:02:44 +0000',
'Subject': '[Bug 71681] Enable "import" on fa.wikivoyage',
'X-Bugzilla-Assigned-To': 'wikibugs-l@lists.wikimedia.org',
'X-Bugzilla-Changed-Fields': '',
'X-Bugzilla-Component': 'Site requests',
'X-Bugzilla-Flags': '',
'X-Bugzilla-Keywords': 'shell',
'X-Bugzilla-Priority': 'Normal',
'X-Bugzilla-Product': 'Wikimedia',
'X-Bugzilla-Reason': 'AssignedTo CC',
'X-Bugzilla-Severity': 'enhancement',
'X-Bugzilla-Status': 'PATCH_TO_REVIEW',
'X-Bugzilla-Target-Milestone': '---',
'X-Bugzilla-Type': 'changed',
'X-Bugzilla-URL': 'https://bugzilla.wikimedia.org/',
'X-Bugzilla-Version': 'wmf-deployment',
'X-Bugzilla-Watch-Reason': 'None',
'X-Bugzilla-Who': 'gerritadmin@wikimedia.org',
'comment': 'Change 164933 merged by jenkins-bot:\n'
'Enable "import" on fa.wikivoyage\n'
'\n'
'https://gerrit.wikimedia.org/r/164933\n',
'commentnumber': 4,
'email': 'gerritadmin@wikimedia.org',
'realname': 'Gerrit Notification Bot',
'shorturl': 'https://bugzilla.wikimedia.org/71681',
'shorturltocomment': 'https://bugzilla.wikimedia.org/71681#c4',
'summary': 'Enable "import" on fa.wikivoyage',
'url': 'https://bugzilla.wikimedia.org/show_bug.cgi?id=71681'}```
and use the same [[ https://github.com/wikimedia/labs-tools-pywikibugs/blob/master/pywikibugs.py#L90 | output logic ]]. However, as you can see, the internal format (and thus also the output logic) are pretty bugzilla-specific, due to all the X-Bugzilla parameters. Those are also used in the output logic. In addition, Bugzilla //concepts// are used extensively, such as the Product»Component setup, as well as the names of priorities and severities. Do we have severities in Phab?
2) Only use the same input (from redis) and output (to IRC). I think this will be less work, but by keeping the underlying base, we keep the current stability.
**However**. The mail format used by phab is still not machine-parsable, so we end up needing the same hacks as in bugzilla. To make matters worse, the Phab format looks even less machine readable -- different contexts are only separated by newlines, and the format is more 'human' than bugzilla's. A few examples:
1)
```qgil changed the title from "Wikibugs IRC bot should stream Phabricator activity" to "IRC bot to report Phabricator activity exactly like Wikibugs does with Bugzilla".
```
-- I have no clue what that would to with titles with "'s
2)
```
greg added a blocking task: T504: Have wikiphabot follow the same channel announce rules as wikibugs.
```
(note the 'blocking')
3)
```jdforrester moved this task to Need discussion on the Wikimedia Phabricator Day 1 workboard.```
(even for a human that has two possible meanings)
4)
```Revi added a subscriber: Revi.```
vs
```qgil added subscribers: mmodell, Rush, yuvipanda.```