diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..722d5e71d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/zubhub_backend/Makefile b/zubhub_backend/Makefile index fadee265b..878621ae2 100644 --- a/zubhub_backend/Makefile +++ b/zubhub_backend/Makefile @@ -151,4 +151,4 @@ destroy: ## Remove stopped containers, networks not currently in use, images no .PHONY: destroy .env: ## Generate a .env file for local development - bash ./compose/make_backend_env.sh ./.env \ No newline at end of file + bash ./compose/make_backend_env.sh ./.env diff --git a/zubhub_backend/compose/celery/requirements.txt b/zubhub_backend/compose/celery/requirements.txt index e9941002d..4af6f4977 100644 --- a/zubhub_backend/compose/celery/requirements.txt +++ b/zubhub_backend/compose/celery/requirements.txt @@ -84,3 +84,4 @@ vine>=1.3.0 watchdog>=0.10.2 wcwidth>=0.2.5 whitenoise>=4.1.4 +django-extensions>=1.0.0 diff --git a/zubhub_backend/zubhub/creators/adapter.py b/zubhub_backend/zubhub/creators/adapter.py index eab3110f0..aa4d69143 100644 --- a/zubhub_backend/zubhub/creators/adapter.py +++ b/zubhub_backend/zubhub/creators/adapter.py @@ -151,31 +151,32 @@ def send_group_invite_mail(self, group_invite_confirmation): self.send_mail( email_template, group_invite_confirmation.creator.email, ctx) - def send_mass_email(self, template_prefix, contexts): - if settings.ENVIRONMENT == "production" and not settings.DEBUG: + def send_mass_email(self, template_prefix, contexts, full_template=False): + if not full_template: template_prefix = "projects/email/" + template_prefix - connection = get_connection( - username=None, password=None, fail_silently=False) - messages = [] - for ctx in contexts: - msg = self.render_mail(template_prefix, ctx["email"], ctx) - messages.append(msg) - - return connection.send_messages(messages) - - def send_mass_text(self, template_prefix, contexts): - if settings.ENVIRONMENT == "production" and not settings.DEBUG: + connection = get_connection( + username=None, password=None, fail_silently=False) + messages = [] + for ctx in contexts: + msg = self.render_mail(template_prefix, ctx["email"], ctx) + messages.append(msg) + + return connection.send_messages(messages) + + def send_mass_text(self, template_prefix, contexts, full_template=False): + template_name = template_prefix + if not full_template: template_name = "projects/phone/" + template_prefix + "_message.txt" - client = Client(settings.TWILIO_ACCOUNT_SID, - settings.TWILIO_AUTH_TOKEN) + client = Client(settings.TWILIO_ACCOUNT_SID, + settings.TWILIO_AUTH_TOKEN) - rendered_text = self.render_text( - template_name, contexts[0]["phone"], contexts[0]) + rendered_text = self.render_text( + template_name, contexts[0]["phone"], contexts[0]) - bindings = list(map(lambda context: json.dumps( - {'binding_type': 'sms', 'address': context["phone"]}), contexts)) + bindings = list(map(lambda context: json.dumps( + {'binding_type': 'sms', 'address': context["phone"]}), contexts)) - client.notify.services(settings.TWILIO_NOTIFY_SERVICE_SID).notifications.create( - to_binding=bindings, - body=rendered_text["body"] - ) + client.notify.services(settings.TWILIO_NOTIFY_SERVICE_SID).notifications.create( + to_binding=bindings, + body=rendered_text["body"] + ) diff --git a/zubhub_backend/zubhub/creators/migrations/0005_alter_setting_contact.py b/zubhub_backend/zubhub/creators/migrations/0005_alter_setting_contact.py new file mode 100644 index 000000000..4d986f804 --- /dev/null +++ b/zubhub_backend/zubhub/creators/migrations/0005_alter_setting_contact.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2 on 2022-03-20 21:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('creators', '0004_auto_20220222_0254'), + ] + + operations = [ + migrations.AlterField( + model_name='setting', + name='contact', + field=models.PositiveSmallIntegerField(blank=True, choices=[(1, 'WHATSAPP'), (2, 'EMAIL'), (3, 'SMS'), (4, 'WEB')], default=3, null=True), + ), + ] diff --git a/zubhub_backend/zubhub/creators/model_utils.py b/zubhub_backend/zubhub/creators/model_utils.py new file mode 100644 index 000000000..a88452f84 --- /dev/null +++ b/zubhub_backend/zubhub/creators/model_utils.py @@ -0,0 +1,32 @@ +from django.core.exceptions import FieldDoesNotExist + +from django.contrib.auth import get_user_model + + +def user_field(user, field, *args): + """ + Gets or sets (optional) user model fields. No-op if fields do not exist. + """ + if not field: + return + User = get_user_model() + try: + field_meta = User._meta.get_field(field) + max_length = field_meta.max_length + except FieldDoesNotExist: + if not hasattr(user, field): + return + max_length = None + if args: + # Setter + v = args[0] + if v: + v = v[0:max_length] + setattr(user, field, v) + else: + # Getter + return getattr(user, field) + + +def user_phone(user, *args): + return user_field(user, "phone", *args) diff --git a/zubhub_backend/zubhub/creators/models.py b/zubhub_backend/zubhub/creators/models.py index ef20781a7..2fed1b7a5 100644 --- a/zubhub_backend/zubhub/creators/models.py +++ b/zubhub_backend/zubhub/creators/models.py @@ -11,7 +11,7 @@ from django.contrib.postgres.indexes import GinIndex from .managers import PhoneNumberManager -from .utils import user_phone +from .model_utils import user_phone try: from allauth.account import app_settings as allauth_settings @@ -83,11 +83,13 @@ class Setting(models.Model): WHATSAPP = 1 EMAIL = 2 SMS = 3 + WEB = 4 CONTACT_CHOICES = ( (WHATSAPP, 'WHATSAPP'), (EMAIL, 'EMAIL'), - (SMS, 'SMS') + (SMS, 'SMS'), + (WEB, 'WEB') ) creator = models.OneToOneField( diff --git a/zubhub_backend/zubhub/creators/tasks.py b/zubhub_backend/zubhub/creators/tasks.py index 6f00b027f..d77dd0255 100644 --- a/zubhub_backend/zubhub/creators/tasks.py +++ b/zubhub_backend/zubhub/creators/tasks.py @@ -34,18 +34,18 @@ def send_whatsapp(self, phone, template_name, ctx): @shared_task(name="creators.tasks.send_mass_email", bind=True, acks_late=True, max_retries=10) -def send_mass_email(self, template_name, ctxs): +def send_mass_email(self, template_name, ctxs, full_template=False): try: - get_adapter().send_mass_email(template_name, ctxs) + get_adapter().send_mass_email(template_name, ctxs, full_template) except Exception as e: raise self.retry(exc=e, countdown=int( uniform(2, 4) ** self.request.retries)) @shared_task(name="creators.tasks.send_mass_text", bind=True, acks_late=True, max_retries=10) -def send_mass_text(self, template_name, ctxs): +def send_mass_text(self, template_name, ctxs, full_template=False): try: - get_adapter().send_mass_text(template_name, ctxs) + get_adapter().send_mass_text(template_name, ctxs, full_template) except Exception as e: raise self.retry(exc=e, countdown=int( uniform(2, 4) ** self.request.retries)) diff --git a/zubhub_backend/zubhub/creators/utils.py b/zubhub_backend/zubhub/creators/utils.py index ee6aa7071..145096a92 100644 --- a/zubhub_backend/zubhub/creators/utils.py +++ b/zubhub_backend/zubhub/creators/utils.py @@ -1,12 +1,18 @@ from datetime import timedelta from django.contrib.postgres.search import SearchQuery, SearchRank from django.db.models import F +from typing import List, Set, Dict, cast from django.core.exceptions import FieldDoesNotExist from django.db import transaction from django.utils import timezone from django.contrib.auth import get_user_model from projects.tasks import delete_file_task from creators.tasks import upload_file_task, send_mass_email, send_mass_text, send_whatsapp +from creators.models import Setting +from notifications.models import Notification +from notifications.utils import push_notification +from creators.models import Creator +from django.template.loader import render_to_string try: from allauth.account.adapter import get_adapter @@ -368,40 +374,63 @@ def enforce_creator__creator_tags_constraints(creator, tag): -def send_notification(users, contexts, template_name): - from .models import Setting +enabled_notification_settings: Dict[Notification.Type, Set[int]] = { + Notification.Type.BOOKMARK: {Setting.WEB}, + Notification.Type.CLAP: {Setting.WEB}, + Notification.Type.COMMENT: {Setting.WHATSAPP, Setting.EMAIL, Setting.SMS, Setting.WEB}, + Notification.Type.FOLLOW: {Setting.WHATSAPP, Setting.EMAIL, Setting.SMS, Setting.WEB}, + Notification.Type.FOLLOWING_PROJECT: + {Setting.WHATSAPP, Setting.EMAIL, Setting.SMS, Setting.WEB}, +} + +def is_valid_setting(setting: int, notification_type: Notification.Type) -> bool: + return setting in enabled_notification_settings[notification_type] + + +html_based_contacts = {Setting.WEB} +def get_notification_template_name( + contact_method: int, notification_type: Notification.Type) -> str: + file_extension = '.html' if contact_method in html_based_contacts else '.txt' + if contact_method == Setting.EMAIL: + file_extension = '' + return (f'notifications/{notification_type.name.lower()}' + f'/{Setting.CONTACT_CHOICES[cast(int, contact_method) - 1][1].lower()}{file_extension}') + + +def send_notification(users: List[Creator], source: Creator, contexts, + notification_type: Notification.Type, link: str) -> None: email_contexts = [] sms_contexts = [] for user, context in zip(users, contexts): user_setting = Setting.objects.get(creator=user) + context.update({'source': user.username}) - if user.phone and user_setting.contact == Setting.WHATSAPP: + if user.phone and user_setting.contact == Setting.WHATSAPP and is_valid_setting(Setting.WHATSAPP, notification_type): context.update({"phone": user.phone}) - send_whatsapp( - phone=user.phone, - template_name=template_name, - ctx=context) + send_whatsapp.delay(phone=user.phone, + template_name=get_notification_template_name(Setting.WHATSAPP, notification_type), + ctx=context) - if user.email and user_setting.contact == Setting.EMAIL: + if user.email and user_setting.contact == Setting.EMAIL and is_valid_setting(Setting.EMAIL, notification_type): context.update({"email": user.email}) email_contexts.append(context) - if user.phone and user_setting.contact == Setting.SMS: + if user.phone and user_setting.contact == Setting.SMS and is_valid_setting(Setting.SMS, notification_type): context.update({"phone": user.phone}) sms_contexts.append(context) + message = render_to_string( + get_notification_template_name(Setting.WEB, notification_type), + context + ).strip() + push_notification(user, source, notification_type, message, link) + if len(email_contexts) > 0: - send_mass_email.delay( - template_name=template_name, - ctxs=email_contexts - ) + send_mass_email.delay(template_name=get_notification_template_name(Setting.EMAIL, notification_type), ctxs=email_contexts, full_template=True) if len(sms_contexts) > 0: - send_mass_text.delay( - template_name=template_name, - ctxs=sms_contexts - ) + send_mass_text.delay(template_name=get_notification_template_name(Setting.SMS, notification_type), ctxs=sms_contexts, full_template=True) # def sync_user_email_addresses(user): diff --git a/zubhub_backend/zubhub/creators/views.py b/zubhub_backend/zubhub/creators/views.py index ba75a29cc..078277fcd 100644 --- a/zubhub_backend/zubhub/creators/views.py +++ b/zubhub_backend/zubhub/creators/views.py @@ -1,6 +1,7 @@ import csv from io import StringIO from django.utils.translation import ugettext_lazy as _ +from notifications.models import Notification from rest_framework import status from django.http import Http404 from django.contrib.auth import get_user_model @@ -361,6 +362,8 @@ def get_object(self): else: obj.followers.add(self.request.user) obj.save() + + send_notification([obj], self.request.user, [{}], Notification.Type.FOLLOW, f'/profile/{self.request.user.username}') self.request.user.save() return obj diff --git a/zubhub_backend/zubhub/notifications/migrations/0005_alter_notification_type.py b/zubhub_backend/zubhub/notifications/migrations/0005_alter_notification_type.py new file mode 100644 index 000000000..2f4bbaad9 --- /dev/null +++ b/zubhub_backend/zubhub/notifications/migrations/0005_alter_notification_type.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2 on 2022-03-20 21:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('notifications', '0004_notification_link'), + ] + + operations = [ + migrations.AlterField( + model_name='notification', + name='type', + field=models.PositiveSmallIntegerField(choices=[(1, 'Bookmark'), (2, 'Clap'), (3, 'Comment'), (4, 'Follow'), (5, 'Following Project')]), + ), + ] diff --git a/zubhub_backend/zubhub/notifications/migrations/0006_notification_message.py b/zubhub_backend/zubhub/notifications/migrations/0006_notification_message.py new file mode 100644 index 000000000..b32be2d0f --- /dev/null +++ b/zubhub_backend/zubhub/notifications/migrations/0006_notification_message.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2 on 2022-03-20 21:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('notifications', '0005_alter_notification_type'), + ] + + operations = [ + migrations.AddField( + model_name='notification', + name='message', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/zubhub_backend/zubhub/notifications/migrations/0007_alter_notification_link.py b/zubhub_backend/zubhub/notifications/migrations/0007_alter_notification_link.py new file mode 100644 index 000000000..cc14ff7b6 --- /dev/null +++ b/zubhub_backend/zubhub/notifications/migrations/0007_alter_notification_link.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2 on 2022-03-22 01:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('notifications', '0006_notification_message'), + ] + + operations = [ + migrations.AlterField( + model_name='notification', + name='link', + field=models.CharField(blank=True, max_length=1000, null=True), + ), + ] diff --git a/zubhub_backend/zubhub/notifications/models.py b/zubhub_backend/zubhub/notifications/models.py index edfe52c6d..d13f69ccd 100644 --- a/zubhub_backend/zubhub/notifications/models.py +++ b/zubhub_backend/zubhub/notifications/models.py @@ -7,10 +7,11 @@ class Notification(models.Model): class Type(models.IntegerChoices): - CLAP = 1 - COMMENT = 2 - SAVE = 3 + BOOKMARK = 1 + CLAP = 2 + COMMENT = 3 FOLLOW = 4 + FOLLOWING_PROJECT = 5 id = models.UUIDField( primary_key=True, default=uuid.uuid4, editable=False, unique=True) @@ -21,6 +22,7 @@ class Type(models.IntegerChoices): Creator, on_delete=models.CASCADE, null=True, related_name="notification_recipient", blank=True) source = models.ForeignKey( Creator, on_delete=models.CASCADE, null=True, related_name="notification_source", blank=True) - link = models.URLField(max_length=1000) + message = models.CharField(max_length=255, blank=True, null=True) + link = models.CharField(max_length=1000, blank=True, null=True) viewed = models.BooleanField(default=False) date = models.DateTimeField(default=timezone.now) diff --git a/zubhub_backend/zubhub/notifications/utils.py b/zubhub_backend/zubhub/notifications/utils.py index 912e18e25..3588f97d0 100644 --- a/zubhub_backend/zubhub/notifications/utils.py +++ b/zubhub_backend/zubhub/notifications/utils.py @@ -1,6 +1,5 @@ from notifications.models import Notification -from django.utils import timezone -def push_notification(recipient, source, type, link): - return Notification.objects.create(recipient=recipient, source=source, type=type, link=link) +def push_notification(recipient, source, notification_type, message, link): + return Notification.objects.create(recipient=recipient, source=source, type=notification_type, message=message, link=link) diff --git a/zubhub_backend/zubhub/projects/views.py b/zubhub_backend/zubhub/projects/views.py index 32ac9f70d..9bfadc0b0 100644 --- a/zubhub_backend/zubhub/projects/views.py +++ b/zubhub_backend/zubhub/projects/views.py @@ -1,6 +1,7 @@ from django.shortcuts import get_object_or_404 from django.http import Http404 from django.utils.translation import ugettext_lazy as _ +from notifications.models import Notification from rest_framework.response import Response from django.contrib.auth.models import AnonymousUser from django.contrib.postgres.search import TrigramSimilarity, SearchQuery, SearchRank @@ -18,7 +19,7 @@ from .utils import (ProjectSearchCriteria, project_changed, detect_mentions, perform_project_search, can_view, get_published_projects_for_user) -from creators.utils import activity_notification +from creators.utils import activity_notification, send_notification from .serializers import (ProjectSerializer, ProjectListSerializer, CommentSerializer, CategorySerializer, TagSerializer, StaffPickSerializer) @@ -54,6 +55,14 @@ def perform_create(self, serializer): serializer.save(creator=self.request.user) self.request.user.save() + if self.request.user.followers is not None: + send_notification( + list(self.request.user.followers.all()), + self.request.user, + [{} for _ in list(self.request.user.followers.all())], + Notification.Type.FOLLOWING_PROJECT, + f'/profile/{self.request.user.username}' + ) class ProjectUpdateAPIView(UpdateAPIView): """ @@ -312,6 +321,14 @@ def get_object(self): obj.likes.add(self.request.user) obj.save() + send_notification( + [obj.creator], + self.request.user, + [{}], + Notification.Type.CLAP, + f'/projects/{obj.pk}' + ) + return obj else: raise PermissionDenied( @@ -347,6 +364,14 @@ def get_object(self): obj.saved_by.add(self.request.user) obj.save() + send_notification( + [obj.creator], + self.request.user, + [{}], + Notification.Type.BOOKMARK, + f'/projects/{obj.pk}' + ) + return obj else: raise PermissionDenied( @@ -423,11 +448,19 @@ def create(self, request, *args, **kwargs): "project_id": result.pk, "creator": request.user.username }) + send_notification( + [result.creator], + self.request.user, + [{}], + Notification.Type.COMMENT, + f'/projects/{result.pk}' + ) return Response(ProjectSerializer(result, context={ 'request': request }).data, status=status.HTTP_201_CREATED) + class CategoryListAPIView(ListAPIView): diff --git a/zubhub_backend/zubhub/templates/creators/phone/notification.txt b/zubhub_backend/zubhub/templates/creators/phone/notification.txt deleted file mode 100644 index 1f8a05f16..000000000 --- a/zubhub_backend/zubhub/templates/creators/phone/notification.txt +++ /dev/null @@ -1 +0,0 @@ -Notification Testing \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/notifications/bookmark/web.html b/zubhub_backend/zubhub/templates/notifications/bookmark/web.html new file mode 100644 index 000000000..0c83e82ad --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/bookmark/web.html @@ -0,0 +1 @@ +{{ source }} bookmarked your project {{ project }} diff --git a/zubhub_backend/zubhub/templates/notifications/clap/web.html b/zubhub_backend/zubhub/templates/notifications/clap/web.html new file mode 100644 index 000000000..aa5f95217 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/clap/web.html @@ -0,0 +1 @@ +{{ source }} clapped for your project {{ project }} diff --git a/zubhub_backend/zubhub/templates/notifications/comment/email_message.html b/zubhub_backend/zubhub/templates/notifications/comment/email_message.html new file mode 100644 index 000000000..17aaf9110 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/comment/email_message.html @@ -0,0 +1,19 @@ + + + + + + + + + + {% load account %} {% load i18n %} {% load default_template_tags %} + {% autoescape off %} + +

{% default_display_name %} New Comment On Your Project

+

{{ source }}

+ + diff --git a/zubhub_backend/zubhub/templates/notifications/comment/email_subject.txt b/zubhub_backend/zubhub/templates/notifications/comment/email_subject.txt new file mode 100644 index 000000000..44c0819a4 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/comment/email_subject.txt @@ -0,0 +1,4 @@ +{% load i18n %} +{% autoescape off %} +{% blocktrans %}New Comment on Your Project{% endblocktrans %} +{% endautoescape %} diff --git a/zubhub_backend/zubhub/templates/notifications/comment/sms.txt b/zubhub_backend/zubhub/templates/notifications/comment/sms.txt new file mode 100644 index 000000000..3bce175b0 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/comment/sms.txt @@ -0,0 +1 @@ +You received a comment on your project! diff --git a/zubhub_backend/zubhub/templates/notifications/comment/web.html b/zubhub_backend/zubhub/templates/notifications/comment/web.html new file mode 100644 index 000000000..5c83944b4 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/comment/web.html @@ -0,0 +1 @@ +{{ source }} commented on your project {{ project }}. diff --git a/zubhub_backend/zubhub/templates/notifications/comment/whatsapp.txt b/zubhub_backend/zubhub/templates/notifications/comment/whatsapp.txt new file mode 100644 index 000000000..3bce175b0 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/comment/whatsapp.txt @@ -0,0 +1 @@ +You received a comment on your project! diff --git a/zubhub_backend/zubhub/templates/notifications/follow/email_message.html b/zubhub_backend/zubhub/templates/notifications/follow/email_message.html new file mode 100644 index 000000000..e15a45c5f --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/follow/email_message.html @@ -0,0 +1,21 @@ + + + + + + + + + + {% load account %} {% load i18n %} {% load default_template_tags %} + {% autoescape off %} + +

+ {% default_display_name %} New folllower +

+

{{ source }}

+ + diff --git a/zubhub_backend/zubhub/templates/notifications/follow/email_subject.txt b/zubhub_backend/zubhub/templates/notifications/follow/email_subject.txt new file mode 100644 index 000000000..561a00a88 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/follow/email_subject.txt @@ -0,0 +1,4 @@ +{% load i18n %} +{% autoescape off %} +{% blocktrans %}You Received a New Follower{% endblocktrans %} +{% endautoescape %} diff --git a/zubhub_backend/zubhub/templates/notifications/follow/sms.txt b/zubhub_backend/zubhub/templates/notifications/follow/sms.txt new file mode 100644 index 000000000..e1b2d8a4b --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/follow/sms.txt @@ -0,0 +1 @@ +{{ source }} just followed you! diff --git a/zubhub_backend/zubhub/templates/notifications/follow/web.html b/zubhub_backend/zubhub/templates/notifications/follow/web.html new file mode 100644 index 000000000..422fd2d51 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/follow/web.html @@ -0,0 +1 @@ +{{ source }} started following you. diff --git a/zubhub_backend/zubhub/templates/notifications/follow/whatsapp.txt b/zubhub_backend/zubhub/templates/notifications/follow/whatsapp.txt new file mode 100644 index 000000000..e1b2d8a4b --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/follow/whatsapp.txt @@ -0,0 +1 @@ +{{ source }} just followed you! diff --git a/zubhub_backend/zubhub/templates/notifications/following_project/email_message.html b/zubhub_backend/zubhub/templates/notifications/following_project/email_message.html new file mode 100644 index 000000000..3c9fbc499 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/following_project/email_message.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + {% load account %} {% load i18n %} {% load default_template_tags %} + {% autoescape off %} + +

{% default_display_name %} New Project

+

{{ source }}

+ + + diff --git a/zubhub_backend/zubhub/templates/notifications/following_project/email_subject.txt b/zubhub_backend/zubhub/templates/notifications/following_project/email_subject.txt new file mode 100644 index 000000000..487a2c398 --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/following_project/email_subject.txt @@ -0,0 +1,4 @@ +{% load i18n %} +{% autoescape off %} +{% blocktrans %}Someone You Are Following Posted a New Project.{% endblocktrans %} +{% endautoescape %} diff --git a/zubhub_backend/zubhub/templates/notifications/following_project/sms.txt b/zubhub_backend/zubhub/templates/notifications/following_project/sms.txt new file mode 100644 index 000000000..684b0d48d --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/following_project/sms.txt @@ -0,0 +1 @@ +New project from {{ source }} diff --git a/zubhub_backend/zubhub/templates/notifications/following_project/web.html b/zubhub_backend/zubhub/templates/notifications/following_project/web.html new file mode 100644 index 000000000..c60e22faa --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/following_project/web.html @@ -0,0 +1 @@ +{{ source }} just posted a new project {{ project }} diff --git a/zubhub_backend/zubhub/templates/notifications/following_project/whatsapp.txt b/zubhub_backend/zubhub/templates/notifications/following_project/whatsapp.txt new file mode 100644 index 000000000..684b0d48d --- /dev/null +++ b/zubhub_backend/zubhub/templates/notifications/following_project/whatsapp.txt @@ -0,0 +1 @@ +New project from {{ source }} diff --git a/zubhub_backend/zubhub/zubhub/settings.py b/zubhub_backend/zubhub/zubhub/settings.py index 5a50c8470..fb8b87243 100644 --- a/zubhub_backend/zubhub/zubhub/settings.py +++ b/zubhub_backend/zubhub/zubhub/settings.py @@ -293,7 +293,8 @@ EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' CELERY_EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -DEFAULT_FROM_EMAIL = 'hello@unstructured.studio' +EMAIL_SUBJECT_PREFIX = '' +DEFAULT_FROM_EMAIL = os.environ.get("DEFAULT_FROM_EMAIL", "hello@unstructured.studio") EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_HOST_USER = 'apikey' EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_API_KEY')