5 from .misc
import Object
7 class Campaigns(Object
):
8 async def send(self
, template
, promotional
=True, **kwargs
):
10 Sends a message to all users that have consented to promotional messages
12 for account
in self
.backend
.accounts
.subscribed
:
14 account
.send_message(template
, **kwargs
)
16 # Remember that we sent a promotional message
18 account
.promotional_message_sent()
20 async def donate(self
):
22 Runs the donation campain, i.e. sends an email once every two months.
24 t
= datetime
.datetime
.now() - datetime
.timedelta(days
=60)
26 for account
in self
.backend
.accounts
.subscribed
:
27 # Fall through if we have no timestamp
28 if account
.last_promotional_message_sent_at
is None:
31 # Fall through if we have passed the threshold
32 elif account
.last_promotional_message_sent_at
<= t
:
35 # If nothing matched, we skip this user
39 # Send a donation reminder
40 account
.send_message("auth/messages/donation-reminder")
42 # Remember that we sent a promotional message
43 account
.promotional_message_sent()