amelioration(BalancerDeliveryMethod): evite d'envoyer les mails av PJ car pour le moment c'est une fonction payante chez Dolist 🤯

This commit is contained in:
Martin 2023-02-03 16:30:40 +01:00 committed by mfo
parent 6a25120f80
commit f952e42ad1

View file

@ -47,8 +47,12 @@ class BalancerDeliveryMethod
def delivery_method(mail)
return mail[FORCE_DELIVERY_METHOD_HEADER].value.to_sym if force_delivery_method?(mail)
@delivery_methods
compatible_delivery_methods_for(mail)
.flat_map { |delivery_method, weight| [delivery_method] * weight }
.sample(random: self.class.random)
end
def compatible_delivery_methods_for(mail)
@delivery_methods.reject { |delivery_method, _weight| delivery_method.to_s == 'dolist_api' && !Dolist::API.sendable?(mail) }
end
end