-
-
{{ msg.text | nl2br }}
-
+ {% set own_message = msg.user_id == user.id %}
+
+
+
+
{{ msg.text | nl2br }}
+
+ {{ msg.created_at.format(__('Y-m-d H:i')) }}
+ {% if own_message %}
-
-
-
-
- {% else %}
-
-
-
-
{{ msg.text | nl2br }}
-
- {{ msg.created_at.format(__('Y-m-d H:i')) }}
-
- {% if msg.read == false %}
-
{% endif %}
+ {% if not own_message and msg.read == false %}
+
+ {% endif %}
- {% endif %}
+
{% endfor %}
@@ -56,7 +46,7 @@
-
+
{{ f.submit(m.icon('send-fill')) }}
diff --git a/src/Controllers/MessagesController.php b/src/Controllers/MessagesController.php
index 9be1ebab..3c6db84c 100644
--- a/src/Controllers/MessagesController.php
+++ b/src/Controllers/MessagesController.php
@@ -179,7 +179,7 @@ class MessagesController extends BaseController
$newMessage->read = $otherUser->id == $currentUser->id; // if its to myself, I obviously read it.
$newMessage->save();
- return $this->redirect->to('/messages/' . $otherUser->id);
+ return $this->redirect->to('/messages/' . $otherUser->id . '#newest');
}
/**
@@ -199,7 +199,7 @@ class MessagesController extends BaseController
throw new HttpForbidden('You can not delete a message you haven\'t send');
}
- return $this->redirect->to('/messages/' . $otherUserId);
+ return $this->redirect->to('/messages/' . $otherUserId . '#newest');
}
/**
diff --git a/tests/Unit/Controllers/MessagesControllerTest.php b/tests/Unit/Controllers/MessagesControllerTest.php
index 81243b03..cca8ed96 100644
--- a/tests/Unit/Controllers/MessagesControllerTest.php
+++ b/tests/Unit/Controllers/MessagesControllerTest.php
@@ -443,7 +443,7 @@ class MessagesControllerTest extends ControllerTest
$this->response->expects($this->once())
->method('redirectTo')
- ->with('http://localhost/messages/' . $this->userB->id)
+ ->with('http://localhost/messages/' . $this->userB->id . '#newest')
->willReturn($this->response);
$this->controller->send($this->request);
@@ -465,7 +465,7 @@ class MessagesControllerTest extends ControllerTest
$this->response->expects($this->once())
->method('redirectTo')
- ->with('http://localhost/messages/' . $this->userA->id)
+ ->with('http://localhost/messages/' . $this->userA->id . '#newest')
->willReturn($this->response);
$this->controller->send($this->request);
@@ -511,7 +511,7 @@ class MessagesControllerTest extends ControllerTest
$this->response->expects($this->once())
->method('redirectTo')
- ->with('http://localhost/messages/1')
+ ->with('http://localhost/messages/1#newest')
->willReturn($this->response);
$this->controller->delete($this->request);