QueryJane | Created periodic task to send notifications about new messages.
utopian-io·@kit.andres·
0.000 HBDQueryJane | Created periodic task to send notifications about new messages.
QueryJane is a web application developed with Django that allows to connect with companies and experts in different sectors of the cannabis industry. Beta version is available [here](https://queryjane.net/). <center>  </center> Users can manage their email notifications settings in their account settings page. Among the options that they can configure, are the option to receive email notifications when they receive new messages from users, and the option to receive email notifications when the companies they manage receive new messages from users. If these options are activated, then a user are receiving an email notification each time that he receive a new message from other user, and each time that a user sends a private message to a company managed by him. This procedure has two implications: **1.** A user can receive an email per each new received message, regardless of whether the messages are from the same user. **2.** A very high message range sent every month across the SMPT server. The SMPT integrated service is [mailgun](https://www.mailgun.com/), and it is not free. I have created a periodic task, that will run every Monday, Wednesday and Friday, checking if there are new messages and sending email notifications with a resume of the new messages. In this way, users will not see an email notification per each new received message, but for a group of new messages. ### New Features I have added a new boolean attribute to the User model called `has_new_messages`. This is used to check if the user has received new private messages since last email notification was sent. When a new message is sent, this attribute is set to `True`, and each time that the new periodic task send an email notification, this attributed is set to `False`. This attribute has been added to the Company model to. In this way, we can check if the company has received new messages from users, and can notify to company administrators about new received messages via email. The goal here is that we are notifying about a group of new messages. I have used [huey](http://huey.readthedocs.io/en/latest/getting-started.html), a tasks manager to create the new task called [new_received_messages](https://github.com/roadhousestudio/queryjane_app/blob/master/account/tasks.py), and that allows to check new messages for users and companies. If since last sent email a user has not received new messages and their messages are yet in status "new", he will not be notified. Take a look to the received email when a user has new received messages: <center>  </center> As you can see, messages are grouped by author, and a little portion of the messages are available on the email content. A link to visit inbox page is available at the bottom of the email. Take a look to the received email when a company has received new messages: <center>  </center> This message will be sent to company administrators that have set "True" the email notification to be notified via email about new messages to companies they manage. *** <center>  </center> *** ### How to contribute? [QueryJane](https://queryjane.net/) has been developed using the [Django framework](https://www.djangoproject.com/). You can fork the project, and run it locally is very easy. Follow the steps described in the [open source repository](https://github.com/roadhousestudio/queryjane_app) installation guide. The project has been configured using Docker. you only need to install [Docker](http://docker.com/) and follow these steps. ### Future work. Take a look to our [public trello board](https://trello.com/b/7fkft2vf/queryjane). This is the easiest way to know our roadmap. * SEO optimization. * Javascript files translation. If you want to contribute, please join my [Discord](https://discord.gg/hAmBYg). *** Have happy days ✌ <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@kit.andres/queryjane-or-created-periodic-task-to-send-notifications-about-new-messages">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>