Commit d8b4ba41 authored by Abhilash Raj's avatar Abhilash Raj

Merge branch 'find-list' into 'master'

Add support for finding lists that an address is subscribed to.

See merge request !69
parents b38654af 2a84b456
Pipeline #22146107 passed with stage
in 3 minutes and 58 seconds
......@@ -240,3 +240,27 @@ class Client:
data['username'] = username
data['password'] = password
return self._connection.call('uris', data, 'PATCH')[1]
def find_lists(self, subscriber, role=None, count=50, page=1):
"""
Given a subscriber and a role, return all the list they are subscribed
to with given role.
If no role is specified all the related mailing lists are returned
without duplicates, even though there can potentially be multiple
memberships of a user in a single mailing list.
:param subscriber: The address of the subscriber.
:type subscriber: str
:param role: owner, moderator or subscriber
:type role: str
"""
url = 'lists/find'
data = dict(subscriber=subscriber, count=count, page=page)
if role is not None:
data['role'] = role
response, content = self._connection.call(url, data)
if 'entries' not in content:
return []
return [MailingList(self._connection, entry['self_link'], entry)
for entry in content['entries']]
......@@ -14,6 +14,9 @@ Changes
* `Mailinglist.add_owner` and `Mailinglist.add_moderator` now accept an
additional `display_name` argument that allows associating display names with
these memberships.
* Add a new API ``Client.find_lists`` which allows filtering mailing lists
related to a subscriber. It optionally allows a role, which filters the lists
that the address is subscribed to with that role.
Backwards Incompatible Changes
-------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment