Skip to content

Commit

Permalink
fix: email notifications (#3457)
Browse files Browse the repository at this point in the history
* fix: email-template design

* fix: priority and state new value

* dev: update template with comments, cta text and view issue button.

* dev: fix priority and state

* dev: update data condition

* fix: added avatar url

* fix: comment avatar url

* fix: priority, labels, state design

* style: assignee property

* dev: fix template for comments and profile changes

* fix: spacing between properties

* fix: todo image for state change

* fix: blocking and blocked by value change

* dev: update template summsary

* fix: blocking, duplicate

* fix: comments spacing

* chore: improve `state change` checkbox logic.

* fix: email notification message change

* fix: updated date format

* fix: updates text color

* fix: labels sequence rendering

* fix: schedular time change

---------

Co-authored-by: LAKHAN BAHETI <lakhanbaheti9@gmail.com>
Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com>
  • Loading branch information
4 people committed Jan 24, 2024
1 parent b66f078 commit adf091f
Show file tree
Hide file tree
Showing 5 changed files with 927 additions and 855 deletions.
45 changes: 19 additions & 26 deletions apiserver/plane/bgtasks/email_notification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,30 +164,25 @@ def send_email_notification(
}
)
activity_time = changes.pop("activity_time")
template_data.append(
{
"actor_detail": {
"avatar_url": actor.avatar,
"first_name": actor.first_name,
"last_name": actor.last_name,
},
"changes": changes,
"issue_details": {
"name": issue.name,
"identifier": f"{issue.project.identifier}-{issue.sequence_id}",
},
"activity_time": str(activity_time),
}
)
# Parse the input string into a datetime object
formatted_time = datetime.strptime(activity_time, "%Y-%m-%d %H:%M:%S").strftime("%H:%M %p")

span = f"""<span style='
font-size: 1rem;
font-weight: 700;
line-height: 28px;
"
>
{template_data[0]['actor_detail']['first_name']} {template_data[0]['actor_detail']['last_name']}
</span>"""
if changes:
template_data.append(
{
"actor_detail": {
"avatar_url": actor.avatar,
"first_name": actor.first_name,
"last_name": actor.last_name,
},
"changes": changes,
"issue_details": {
"name": issue.name,
"identifier": f"{issue.project.identifier}-{issue.sequence_id}",
},
"activity_time": str(formatted_time),
}
)

summary = "updates were made to the issue by"

Expand All @@ -204,11 +199,10 @@ def send_email_notification(
"receiver": {
"email": receiver.email,
},
"issue_unsubscribe": f"{base_api}/{str(issue.project.workspace.slug)}/projects/{str(issue.project.id)}/issues/{str(issue.id)}",
"issue_url": f"{base_api}/{str(issue.project.workspace.slug)}/projects/{str(issue.project.id)}/issues/{str(issue.id)}",
"user_preference": f"{base_api}/profile/preferences/email",
"comments": comments,
}
print(json.dumps(context))
html_content = render_to_string(
"emails/notifications/issue-updates.html", context
)
Expand Down Expand Up @@ -236,7 +230,6 @@ def send_email_notification(
EmailNotificationLog.objects.filter(
pk__in=email_notification_ids
).update(sent_at=timezone.now())
print("Email Sent")
return
except Exception as e:
print(e)
Expand Down
6 changes: 5 additions & 1 deletion apiserver/plane/bgtasks/notification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ def notifications(
user_id=subscriber
)

for issue_activity in issue_activities_created:
for issue_activity in issue_activities_created:
# If activity done in blocking then blocked by email should not go
if issue_activity.get("issue_detail").get("id") != issue_id:
continue;

# Do not send notification for description update
if issue_activity.get("field") == "description":
continue
Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"check-every-five-minutes-to-send-email-notifications": {
"task": "plane.bgtasks.email_notification_task.stack_email_notification",
"schedule": crontab(minute='*/1')
"schedule": crontab(minute='*/5')
},
}

Expand Down

0 comments on commit adf091f

Please sign in to comment.