launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19356
[Merge] lp:~cjwatson/launchpad/mail-handle-me into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/mail-handle-me into lp:launchpad.
Commit message:
Treat "me" in person-or-team contexts in mail handlers as the current user.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #340397 in Launchpad itself: "E-mail assignment interface should support "me""
https://bugs.launchpad.net/launchpad/+bug/340397
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/mail-handle-me/+merge/270853
Treat "me" in person-or-team contexts in mail handlers as the current user.
"me" is already reserved on production by +nameblacklist, so this is safe from clashes.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/mail-handle-me into lp:launchpad.
=== modified file 'lib/lp/bugs/tests/bugs-emailinterface.txt'
--- lib/lp/bugs/tests/bugs-emailinterface.txt 2015-07-21 09:04:01 +0000
+++ lib/lp/bugs/tests/bugs-emailinterface.txt 2015-09-11 16:35:55 +0000
@@ -1197,6 +1197,14 @@
>>> debian_task.assignee is None
True
+Also like the web UI, we can assign a bug to "me", the current user.
+
+ >>> submit_commands(
+ ... bug_four, 'affects debian',
+ ... 'assignee me')
+ >>> debian_task.assignee.name
+ u'name12'
+
To set which source package the bug affects, we use:
>>> submit_commands(bug_four, 'affects debian/mozilla-firefox')
=== modified file 'lib/lp/services/mail/helpers.py'
--- lib/lp/services/mail/helpers.py 2015-07-10 15:30:28 +0000
+++ lib/lp/services/mail/helpers.py 2015-09-11 16:35:55 +0000
@@ -161,6 +161,11 @@
"""
# Avoid circular import problems.
from lp.registry.vocabularies import ValidPersonOrTeamVocabulary
+
+ # "me" is a special case meaning the sender of the email.
+ if person_name_or_email == "me":
+ return getUtility(ILaunchBag).user
+
valid_person_vocabulary = ValidPersonOrTeamVocabulary()
try:
person_term = valid_person_vocabulary.getTermByToken(
=== modified file 'lib/lp/services/mail/tests/test_helpers.py'
--- lib/lp/services/mail/tests/test_helpers.py 2012-09-27 20:45:31 +0000
+++ lib/lp/services/mail/tests/test_helpers.py 2015-09-11 16:35:55 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -7,12 +7,16 @@
import time
import unittest
+from zope.component import getUtility
from zope.interface import (
directlyProvidedBy,
directlyProvides,
)
-from lp.registry.interfaces.person import PersonVisibility
+from lp.registry.interfaces.person import (
+ IPersonSet,
+ PersonVisibility,
+ )
from lp.services.mail.helpers import (
ensure_not_weakly_authenticated,
ensure_sane_signature_timestamp,
@@ -239,6 +243,12 @@
self.assertEqual(
team, get_person_or_team('fooix-devs@xxxxxxxxxxxxxxxxx'))
+ def test_me(self):
+ # The special case of "me" refers to the logged-in user, that is,
+ # the user who sent the email being processed.
+ me = getUtility(IPersonSet).getByEmail('test@xxxxxxxxxxxxx')
+ self.assertEqual(me, get_person_or_team('me'))
+
class Testget_contact_email_addresses(TestCaseWithFactory):
Follow ups