-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it work :-P
src/billo.php
Outdated
@@ -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'))) { |
There was a problem hiding this comment.
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:
Line 26 in 08f5dfc
} |
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one bug, so this won't work and I'd like the logic to be moved out of billo.php but apart from that this looks really good now
if(!$subscribed) { | ||
echo "Not distributed message from unknown sender" . PHP_EOL; | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move this logic to the ListsConfigParser. Naming the function is probably the hardest part :-D
... and then:
} | |
if(!$listsConfig->isAnyAddressMemberOfList($message->getHeader('from')->getAddressList(), $list->getEmail())) { | |
continue; | |
} |
Keeps the complexity of this function lower and gives us a chance to unit test it...
// Check at least one of the senders ("from") is subscribed to the list | ||
$subscribed = false; | ||
foreach($message->getHeader('from')->getAddressList() as $from) { | ||
if ($listsConfig->isMember($from->getEmail(), $members)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to pass the list name to isMember
not the members themselves.
if ($listsConfig->isMember($from->getEmail(), $members)) { | |
if ($listsConfig->isMember($from->getEmail(), $list->getEmail())) { |
No description provided.