fix: email notifications (#3457)

* 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>
This commit is contained in:
Bavisetti Narayan 2024-01-24 20:34:32 +05:30 committed by GitHub
parent b66f07845a
commit adf091fa07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 938 additions and 866 deletions

View File

@ -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"
@ -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
)
@ -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)

View File

@ -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

View File

@ -31,7 +31,7 @@ app.conf.beat_schedule = {
},
"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')
},
}

File diff suppressed because it is too large Load Diff

View File

@ -104,7 +104,7 @@ export const EmailNotificationForm: FC<IEmailNotificationFormProps> = (props) =>
type="checkbox"
checked={value}
onChange={() => {
if (!value) setValue("issue_completed", true);
setValue("issue_completed", !value);
onChange(!value);
}}
className="w-3.5 h-3.5 mx-2 cursor-pointer"