diff --git a/chat_thread.html b/chat_thread.html index 81bddd4..cfa7667 100644 --- a/chat_thread.html +++ b/chat_thread.html @@ -148,6 +148,18 @@ textarea#message-content { } .message-container:hover .add-reaction-row { display: flex; +} +.message-content-wrap.align-right { + text-align: right; +} +.message-content-wrap.align-left { + text-align: left; +} +.dark .edit-message-textarea, +.edit-message-textarea.dark-textarea { + background-color: #2a2b2d; + color: #e4e6eb; + border: 1px solid #555; } @@ -193,7 +205,7 @@ textarea#message-content {
{% for msg in messages %} -
+
{% if msg.sender.profile.profile_picture %} Profile Picture @@ -203,17 +215,19 @@ textarea#message-content {
{% endif %}
-
- {{ msg.sender.username }}: {{ msg.content }}
+
+ {{ msg.sender.username }}: + {{ msg.content }} + +
{% if msg.sender == request.user %} - {% if msg.seen %} -
Seen
- {% else %} -
Delivered
- {% endif %} - {% endif %} - {% if msg.sender == request.user %} +
{% if msg.seen %}Seen{% else %}Delivered{% endif %}
{% csrf_token %}
+ {% endif %} {% if msg.reactions.all %} {% with last_reaction=msg.reactions.all.last %} @@ -512,5 +527,77 @@ $(document).on('click', '.reaction-bubble', function() { }); }); + diff --git a/eversyncc/urls.py b/eversyncc/urls.py index 395376b..4e4af1c 100644 --- a/eversyncc/urls.py +++ b/eversyncc/urls.py @@ -80,6 +80,7 @@ urlpatterns = [ path('delete_profile_picture/', views.delete_profile_picture, name='delete_profile_picture'), path('message//add_reaction/', views.add_reaction, name='add_reaction'), path('message//remove_reaction/', views.remove_reaction, name='remove_reaction'), + path('message//edit/', views.edit_message, name='edit_message'), ] if settings.DEBUG: diff --git a/eversyncc/views.py b/eversyncc/views.py index 36ce776..8ec4680 100644 --- a/eversyncc/views.py +++ b/eversyncc/views.py @@ -1454,3 +1454,16 @@ def remove_reaction(request, message_id): return JsonResponse({'error': 'Reaction not found'}, status=404) return JsonResponse({'error': 'Invalid request method'}, status=405) +@email_verified_required +@login_required +def edit_message(request, message_id): + if request.method == "POST": + message = get_object_or_404(Message, id=message_id, sender=request.user) + new_content = request.POST.get("content", "").strip() + if not new_content: + return JsonResponse({"error": "Content cannot be empty."}, status=400) + message.content = new_content + message.save() + return JsonResponse({"success": True, "content": message.content}) + return JsonResponse({"error": "Invalid request method"}, status=405) +