Skip to content

Commit

Permalink
dev: update origin request
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohashescobar committed Jan 23, 2024
1 parent cd08b9e commit b82e20e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 7 deletions.
3 changes: 3 additions & 0 deletions apiserver/plane/app/views/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ def destroy(self, request, slug, project_id, pk):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
# Delete the cycle
cycle.delete()
Expand Down Expand Up @@ -723,6 +724,7 @@ def create(self, request, slug, project_id, cycle_id):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)

# Return all Cycle Issues
Expand Down Expand Up @@ -756,6 +758,7 @@ def destroy(self, request, slug, project_id, cycle_id, issue_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
cycle_issue.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down
2 changes: 2 additions & 0 deletions apiserver/plane/app/views/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def create(self, request, slug, project_id, inbox_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
# create an inbox issue
InboxIssue.objects.create(
Expand Down Expand Up @@ -279,6 +280,7 @@ def partial_update(self, request, slug, project_id, inbox_id, issue_id):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
issue_serializer.save()
else:
Expand Down
24 changes: 23 additions & 1 deletion apiserver/plane/app/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def create(self, request, slug, project_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
issue = (
self.get_queryset().filter(pk=serializer.data["id"]).first()
Expand Down Expand Up @@ -299,6 +300,7 @@ def partial_update(self, request, slug, project_id, pk=None):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
issue = self.get_queryset().filter(pk=pk).first()
return Response(
Expand All @@ -323,6 +325,7 @@ def destroy(self, request, slug, project_id, pk=None):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(status=status.HTTP_204_NO_CONTENT)

Expand Down Expand Up @@ -531,7 +534,7 @@ def get(self, request, slug, project_id, issue_id):

if request.GET.get("activity_type", None) == "issue-property":
return Response(issue_activities, status=status.HTTP_200_OK)

if request.GET.get("activity_type", None) == "issue-comment":
return Response(issue_comments, status=status.HTTP_200_OK)

Expand Down Expand Up @@ -599,6 +602,7 @@ def create(self, request, slug, project_id, issue_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -629,6 +633,7 @@ def partial_update(self, request, slug, project_id, issue_id, pk):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand All @@ -654,6 +659,7 @@ def destroy(self, request, slug, project_id, issue_id, pk):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(status=status.HTTP_204_NO_CONTENT)

Expand Down Expand Up @@ -857,6 +863,7 @@ def post(self, request, slug, project_id, issue_id):
current_instance=json.dumps({"parent": str(sub_issue_id)}),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
for sub_issue_id in sub_issue_ids
]
Expand Down Expand Up @@ -917,6 +924,7 @@ def create(self, request, slug, project_id, issue_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -947,6 +955,7 @@ def partial_update(self, request, slug, project_id, issue_id, pk):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand All @@ -971,6 +980,7 @@ def destroy(self, request, slug, project_id, issue_id, pk):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
issue_link.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down Expand Up @@ -1028,6 +1038,7 @@ def post(self, request, slug, project_id, issue_id):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand All @@ -1045,6 +1056,7 @@ def delete(self, request, slug, project_id, issue_id, pk):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)

return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down Expand Up @@ -1224,6 +1236,7 @@ def unarchive(self, request, slug, project_id, pk=None):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
issue.archived_at = None
issue.save()
Expand Down Expand Up @@ -1370,6 +1383,7 @@ def create(self, request, slug, project_id, issue_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand All @@ -1396,6 +1410,7 @@ def destroy(self, request, slug, project_id, issue_id, reaction_code):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
issue_reaction.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down Expand Up @@ -1437,6 +1452,7 @@ def create(self, request, slug, project_id, comment_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -1464,6 +1480,7 @@ def destroy(self, request, slug, project_id, comment_id, reaction_code):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
comment_reaction.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down Expand Up @@ -1593,6 +1610,7 @@ def create(self, request, slug, project_id, issue_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)

if relation_type == "blocking":
Expand Down Expand Up @@ -1638,6 +1656,7 @@ def remove_relation(self, request, slug, project_id, issue_id):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(status=status.HTTP_204_NO_CONTENT)

Expand Down Expand Up @@ -1810,6 +1829,7 @@ def create(self, request, slug, project_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -1841,6 +1861,7 @@ def partial_update(self, request, slug, project_id, pk):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -1868,5 +1889,6 @@ def destroy(self, request, slug, project_id, pk=None):
current_instance=current_instance,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
return Response(status=status.HTTP_204_NO_CONTENT)
3 changes: 3 additions & 0 deletions apiserver/plane/app/views/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def destroy(self, request, slug, project_id, pk):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
module.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down Expand Up @@ -490,6 +491,7 @@ def create(self, request, slug, project_id, module_id):
),
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)

issues = self.get_queryset().values_list("issue_id", flat=True)
Expand Down Expand Up @@ -522,6 +524,7 @@ def destroy(self, request, slug, project_id, module_id, issue_id):
current_instance=None,
epoch=int(timezone.now().timestamp()),
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
module_issue.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down
6 changes: 3 additions & 3 deletions apiserver/plane/bgtasks/email_notification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Module imports
from plane.db.models import EmailNotificationLog, User, Issue
from plane.license.utils.instance_value import get_email_configuration

from plane.settings.redis import redis_instance

@shared_task
def stack_email_notification():
Expand Down Expand Up @@ -129,7 +129,8 @@ def create_payload(notification_data):
def send_email_notification(
issue_id, notification_data, receiver_id, email_notification_ids
):
base_api = "https://app.plane.so"
ri = redis_instance()
base_api = (ri.get(str(issue_id)).decode())
data = create_payload(notification_data=notification_data)

# Get email configurations
Expand Down Expand Up @@ -160,7 +161,6 @@ def send_email_notification(
"first_name": actor.first_name,
"last_name": actor.last_name,
},
"activity_time": str(activity_time),
}
)
activity_time = changes.pop("activity_time")
Expand Down
7 changes: 6 additions & 1 deletion apiserver/plane/bgtasks/issue_activites_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from plane.app.serializers import IssueActivitySerializer
from plane.bgtasks.notification_task import notifications

from plane.settings.redis import redis_instance

# Track Changes in name
def track_name(
Expand Down Expand Up @@ -1563,6 +1563,7 @@ def issue_activity(
epoch,
subscriber=True,
notification=False,
origin=None,
):
try:
issue_activities = []
Expand All @@ -1571,6 +1572,10 @@ def issue_activity(
workspace_id = project.workspace_id

if issue_id is not None:
if origin:
ri = redis_instance()
# set the request origin in redis
ri.set(str(issue_id), origin, ex=600)
issue = Issue.objects.filter(pk=issue_id).first()
if issue:
try:
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='*/5')
"schedule": crontab(minute='*/1')
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@
border-radius: 4px;
"
>
{{ actor_comment.new_value }}
{{ actor_comment.new_value.0 }}
</div>
</td>
</tr>
Expand Down

0 comments on commit b82e20e

Please sign in to comment.