Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions mailmanapi/apiv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ def members(listname):
return jsonify(mlist.getMembers())


def helds(listname):
"""Lists helds messages for the `listname` list.

**Method**: GET

**URI**: /<listname>/helds

Returns an array of helds messages."""

mlist = get_mailinglist(listname, lock=True)
msgids = mlist.GetHeldMessageIds()
msg = []
for msgid in msgids:
record = mlist.GetRecord(msgid)
msg.append({'from': record[1], 'subject': record[2], 'reason': record[3]})
mlist.Unlock()
return jsonify(msg)

def sendmail(listname):
"""Posts an email to the mailing list.

Expand Down
19 changes: 19 additions & 0 deletions mailmanapi/apiv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,22 @@ def members(listname):
except Errors.MMUnknownListError, e:
return jsonify(ERRORS_CODE[e.__class__.__name__])
return jsonify(mlist.getMembers())

def helds(listname):
"""Lists helds messages for the `listname` list.

**Method**: GET

**URI**: /v2/<listname>/helds

Returns an array of helds messages."""

mlist = get_mailinglist(listname, lock=True)
msgids = mlist.GetHeldMessageIds()
msg = []
for msgid in msgids:
record = mlist.GetRecord(msgid)
msg.append({'from': record[1], 'subject': record[2], 'reason': record[3]})
mlist.Unlock()
return jsonify(msg)

5 changes: 4 additions & 1 deletion mailmanapi/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def create_routes(app):
callback=apiv1.members)
app.route('/<listname>/sendmail', method='POST',
callback=apiv1.sendmail)
app.route('/<listname>/helds', method='GET',
callback=apiv1.helds)

# v2
app.route('/v2/lists/', method='GET',
Expand All @@ -31,7 +33,8 @@ def create_routes(app):
callback=apiv2.members)
app.route('/v2/sendmail/<listname>', method='POST',
callback=apiv2.sendmail)

app.route('/v2/<listname>/helds', method='GET',
callback=apiv2.helds)

def get_application(allowed_ips):
bottle_app = default_app()
Expand Down