Skip to content

Commit

Permalink
Tweak /api/0/tag/ to accept context= argument for "tag all" style ops
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed Oct 23, 2014
1 parent 2ec9ba7 commit 3d388b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion mailpile/httpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ def _real_do_GET(self, post_data={}, suppress_body=False, method='GET'):
self.session = session = Session(config)
session.ui = HttpUserInteraction(self, config,
log_parent=server_session.ui)
if 'context' in query_data:

if 'context' in post_data:
session.load_context(post_data['context'][0])
elif 'context' in query_data:
session.load_context(query_data['context'][0])

if 'http' in config.sys.debug:
Expand Down
8 changes: 4 additions & 4 deletions mailpile/plugins/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ class Tag(TagCommand):
HTTP_POST_VARS = {
'mid': 'message-ids',
'add': 'tags',
'del': 'tags'
'del': 'tags',
'context': 'search context, for tagging relative results'
}

class CommandResult(TagCommand.CommandResult):
Expand All @@ -262,12 +263,11 @@ def as_text(self):
len(self.result['msg_ids']))

def _get_ops_and_msgids(self, words):
ops = (['+%s' % t for t in self.data.get('add', []) if t] +
['-%s' % t for t in self.data.get('del', []) if t])
if 'mid' in self.data:
msg_ids = [int(m.replace('=', ''), 36) for m in self.data['mid']]
ops = (['+%s' % t for t in self.data.get('add', []) if t] +
['-%s' % t for t in self.data.get('del', []) if t])
else:
ops = []
while words and words[0][0] in ('-', '+'):
ops.append(words.pop(0))
msg_ids = self._choose_messages(words)
Expand Down

0 comments on commit 3d388b7

Please sign in to comment.