Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added few properties to issue template #6118

Draft
wants to merge 3 commits into
base: preview
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions apiserver/plane/bgtasks/email_notification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ def release_lock(lock_id):
redis_client = redis_instance()
redis_client.delete(lock_id)

def is_valid_url(url: str) -> bool:
"""Check if URL starts with http:// or https://"""
return url.startswith(("http://", "https://"))


def get_avatar_url(base_host, actor):
# Check if avatar_url is present
if not actor.avatar_url:
return ""

# Check if avatar_url is a valid URL
if is_valid_url(actor.avatar_url):
return actor.avatar_url

# Return the full URL
return f"{base_host}/{actor.avatar_url}"

@shared_task
def stack_email_notification():
Expand Down Expand Up @@ -218,7 +234,7 @@ def send_email_notification(
{
"actor_comments": comment,
"actor_detail": {
"avatar_url": f"{base_api}{actor.avatar_url}",
"avatar_url": get_avatar_url(base_api, actor),
"first_name": actor.first_name,
"last_name": actor.last_name,
},
Expand All @@ -235,7 +251,7 @@ def send_email_notification(
{
"actor_comments": mention,
"actor_detail": {
"avatar_url": f"{base_api}{actor.avatar_url}",
"avatar_url": get_avatar_url(base_api, actor),
"first_name": actor.first_name,
"last_name": actor.last_name,
},
Expand All @@ -251,7 +267,7 @@ def send_email_notification(
template_data.append(
{
"actor_detail": {
"avatar_url": f"{base_api}{actor.avatar_url}",
"avatar_url": get_avatar_url(base_api, actor),
"first_name": actor.first_name,
"last_name": actor.last_name,
},
Expand Down
82 changes: 81 additions & 1 deletion apiserver/templates/emails/notifications/issue-updates.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,87 @@
{% endif %}
</tr>
</table>
{% endif %}
{% endif %} {% if update.changes.relates_to.new_value %} <!-- Relates to changed -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse; margin: 0;margin-bottom:15px; padding: 0; display:inline-block">
<td align="center" valign="middle" style="padding:0; text-align: center; display:inline-block">
<img src="https://plane-marketing.s3.ap-south-1.amazonaws.com/plane-assets/emails/blocking.png" width="12" height="12" border="0" style="margin:0px; padding:0px;margin-right:5px;" />
</td>
<td align="center" valign="middle" style="padding:0; text-align: center;">
<span style="font-size: 0.8rem; font-weight: 500; color: #525252; margin: 0px; display: inline-block;">
Relates to:
</span>
</td>
{% if update.changes.relates_to.new_value.0 %}
<td style="padding-left: 5px;overflow-wrap: break-word;"> {% for relates_to in update.changes.relates_to.new_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-right: 3px; padding-top: 0px; display: inline-block;" > {{ relates_to }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.relates_to.new_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-right: 5px; padding-top: 0px; display: inline-block;" > +{{ update.changes.relates_to.new_value|length|add:"-2" }} more </span> </td>
{% endif %} {% if update.changes.relates_to.old_value.0 %}
<td style="padding-left: 8px;"> {% for relates_to in update.changes.relates_to.old_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 3px; padding-top: 0px; text-decoration: line-through; display:inline-block;" > {{ relates_to }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.relates_to.old_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 5px; padding-top: 0px; display: inline-block;" > +{{ update.changes.relates_to.old_value|length|add:"-2" }} more </span> </td>
{% endif %}
</table>
{% endif %}{% if update.changes.parent.new_value %} <!-- Parent changed -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse; margin: 0;margin-bottom:15px; padding: 0; display:inline-block">
<td align="center" valign="middle" style="padding:0; text-align: center; display:inline-block">
<img src="https://plane-marketing.s3.ap-south-1.amazonaws.com/plane-assets/emails/blocking.png" width="12" height="12" border="0" style="margin:0px; padding:0px;margin-right:5px;" />
</td>
<td align="center" valign="middle" style="padding:0; text-align: center;">
<span style="font-size: 0.8rem; font-weight: 500; color: #525252; margin: 0px; display: inline-block;">
Parent:
</span>
</td>
{% if update.changes.parent.new_value.0 %}
<td style="padding-left: 5px;overflow-wrap: break-word;"> {% for parent in update.changes.parent.new_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-right: 3px; padding-top: 0px; display: inline-block;" > {{ parent }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.parent.new_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-right: 5px; padding-top: 0px; display: inline-block;" > +{{ update.changes.parent.new_value|length|add:"-2" }} more </span> </td>
{% endif %} {% if update.changes.parent.old_value.0 %}
<td style="padding-left: 8px;"> {% for parent in update.changes.parent.old_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 3px; padding-top: 0px; text-decoration: line-through; display:inline-block;" > {{ parent }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.parent.old_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 5px; padding-top: 0px; display: inline-block;" > +{{ update.changes.parent.old_value|length|add:"-2" }} more </span> </td>
{% endif %}
</table>
{% endif %}{% if update.changes.blocked_by.new_value %} <!-- Blocked by changed -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse; margin: 0; margin-bottom:15px; padding: 0; display:inline-block">
<td align="center" valign="middle" style="padding:0; text-align: center; display:inline-block">
<img src="https://plane-marketing.s3.ap-south-1.amazonaws.com/plane-assets/emails/blocking.png" width="12" height="12" border="0" style="margin:0px; padding:0px;margin-right:5px;" />
</td>
<td align="center" valign="middle" style="padding:0; text-align: center;">
<span style="font-size: 0.8rem; font-weight: 500; color: #525252; margin: 0px; display: inline-block;">
Blocked by:
</span>
</td>
{% if update.changes.blocked_by.new_value.0 %}
<td style="padding-left: 5px;overflow-wrap: break-word;"> {% for blocked_by in update.changes.blocked_by.new_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-right: 3px; padding-top: 0px; display: inline-block;" > {{ blocked_by }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.blocked_by.new_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-left: 5px; padding-top: 0px; display: inline-block;" > +{{ update.changes.blocked_by.new_value|length|add:"-2" }} more </span> </td>
{% endif %} {% if update.changes.blocked_by.old_value.0 %}
<td style="padding-left: 8px;"> {% for blocked_by in update.changes.blocked_by.old_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 3px; padding-top: 0px; text-decoration: line-through; display:inline-block;" > {{ blocked_by }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.blocked_by.old_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 5px; padding-top: 0px; display: inline-block;" > +{{ update.changes.blocked_by.old_value|length|add:"-2" }} more </span> </td>
{% endif %}
</table>
{% endif %}{% if update.changes.estimate_point.new_value %} <!-- Estimate point changed -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse; margin: 0;margin-bottom:15px; padding: 0; display:inline-block">
<td align="center" valign="middle" style="padding:0; text-align: center; display:inline-block">
<img src="https://plane-marketing.s3.ap-south-1.amazonaws.com/plane-assets/emails/blocking.png" width="12" height="12" border="0" style="margin:0px; padding:0px;margin-right:5px;" />
</td>
<td align="center" valign="middle" style="padding:0; text-align: center;">
<span style="font-size: 0.8rem; font-weight: 500; color: #525252; margin: 0px; display: inline-block;">
Estimates:
</span>
</td>
{% if update.changes.estimate_point.new_value.0 %}
<td style="padding-left: 5px;overflow-wrap: break-word;"> {% for estimate_point in update.changes.estimate_point.new_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-right: 3px; padding-top: 0px; display: inline-block;" > {{ estimate_point }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.estimate_point.new_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #3a5bc7; margin-right: 3px; padding-top: 0px; display: inline-block;" > +{{ update.changes.estimate_point.new_value|length|add:"-2" }} more </span> </td>
{% endif %} {% if update.changes.estimate_point.old_value.0 %}
<td style="padding-left: 8px;"> {% for estimate_point in update.changes.estimate_point.old_value|slice:":2" %} <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 3px; padding-top: 0px; text-decoration: line-through; display:inline-block;" > {{ estimate_point }} </span> {% endfor %} </td>
{% endif %} {% if update.changes.estimate_point.old_value.2 %}
<td> <span style=" font-size: 0.8rem; font-weight: 500; color: #641723; margin-right: 3px; padding-top: 0px; display: inline-block;" > +{{ update.changes.estimate_point.old_value|length|add:"-2" }} more </span> </td>
{% endif %}
</table>
{% endif %}
</div>
</div>
{% endif %} <!-- Outer update Box end --> {% endfor %} {% if comments.0 %} <!-- Comments outer update Box -->
Expand Down