diff --git a/README.md b/README.md index b1e635b..19abece 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ _Conditions that a message must satisfy for the filter to be applied:_ - `to` - if the message is to a certain name or email address. - `subject` - if the message has a certain subject. - `hasAttachment` - if the message has an attachment. +- `list` - if the message is from a mailing list. - `excludeChats` - exclude chats from the results (false by default). ### Actions diff --git a/src/Model/Filter.php b/src/Model/Filter.php index c7e4d03..ae6c639 100644 --- a/src/Model/Filter.php +++ b/src/Model/Filter.php @@ -97,6 +97,20 @@ class Filter return $this; } + /** + * Filter a message if it was sent from a mailing list. + * + * @param $value The mailing list address + * + * @return $this + */ + public function list($value) + { + $this->has("list:{$value}"); + + return $this; + } + /** * @return $this */ diff --git a/tests/Unit/FilterTest.php b/tests/Unit/FilterTest.php index 84fbf20..e3ff06c 100644 --- a/tests/Unit/FilterTest.php +++ b/tests/Unit/FilterTest.php @@ -134,6 +134,17 @@ class FilterTest extends TestCase ); } + /** + * @covers ::list + */ + public function testList() + { + $this->assertEquals( + ['hasTheWord' => 'list:foobar'], + $this->filter->list('foobar')->toArray() + ); + } + /** * @covers ::excludeChats */