Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sender must be a part of mail list #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions src/ListsConfigParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public function getListName($list) {
public function getLists() {
return array_keys($this->_config);
}

public function isMember($listAdresses, $senderAddress)
{
return in_array($listAdresses, $senderAddress)
}

public function getMembers($listAddress)
{
Expand Down
5 changes: 4 additions & 1 deletion src/billo.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ function main() {
if ($message->hasFlag(Storage::FLAG_SEEN)) {
// continue;
} else {
messageAddFlag($GLOBALS['mailStorage'], $id, $message, Storage::FLAG_SEEN);
if ($listsConfig->isMember($list, $message->getHeader('from'))) {
Copy link
Owner

@dschmidt dschmidt Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look closer at the link I sent you https://github.com/dschmidt/billo/blob/master/src/billo.php#L43

You need to handle an addressList here, as there could be multiple from values.

Apart from that: there is no $list in this scope.
You could probably handle this better here:

with code similar to this:

     $members = $listsConfig->getMembers($list->getEmail());                                                                                     
                                                                                                                                                 
     // Check at least one of the senders ("from") is subscribed to the list                                                                     
     $subscribed = false;                                                                                                                        
     foreach($message->getHeader('from')->getAddressList() as $from) {                                                                           
       if (in_array($from->getEmail(), array_keys($members))) {                                                                                              
         $subscribed = true;                                                                                                                     
       }                                                                                                                                         
     }                                                                                                                                           
     if(!$subscribed) {                                                                                                                          
       continue;                                                                                                                                 
     } 

Please test, I haven't :)

messageAddFlag($GLOBALS['mailStorage'], $id, $message, Storage::FLAG_SEEN);
}
}


distributeMessage($listsConfig, $GLOBALS['mailSender'], $id, $message);
}
Expand Down