Skip to content

Commit c1b7052

Browse files
koray-erenJeff
authored andcommitted
reply message formatting
1 parent c3ae5c8 commit c1b7052

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

sogs/routes/views.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from .. import config, crypto, http
44
from ..model.room import get_accessible_rooms
5+
from .messages import message_single, messages_recent
56
from . import auth, converters # noqa: F401
67

78

@@ -29,6 +30,22 @@ def serve_index():
2930

3031
@views.get("/r/<Room:room>/")
3132
def view_room(room):
33+
messageId = 37
34+
response = ''
35+
print()
36+
try:
37+
response = message_single(room=room, msg_id=messageId)
38+
# response = messages_recent(room=room)
39+
print(' +++ NO ERROR +++ ')
40+
except Exception as e:
41+
print("ERROR MSG: {}".format(e))
42+
43+
if response.status_code == 200:
44+
print(" === EXISTS === ")
45+
print(response.json )
46+
else:
47+
print(" !!! NO MESSAGE !!! ")
48+
print()
3249
if not room.default_read:
3350
abort(http.FORBIDDEN)
3451

sogs/static/view_room.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ const setup = async () => {
5151
{
5252
throw Error(err);
5353
}
54-
54+
5555
const plain = Message.decode(data).dataMessage;
56+
console.log(plain)
57+
// if msg is a reply
58+
if (plain.quote){
59+
originalMsg = document.createElement('p');
60+
originalMsg.classList.add('text-sm', 'italic', 'border-l-2', 'border-sessionGreen', 'pl-2');
61+
authorId = plain.quote.author
62+
authorId = authorId.substr(authorId.length - 8);
63+
originalMsg.appendChild(document.createTextNode("..." + authorId +": "+plain.quote.text));
64+
e.appendChild(originalMsg);
65+
}
5666
e.appendChild(document.createTextNode(plain.profile.displayName +": "+plain.body));
5767
e.classList.add('bg-gray-300','dark:bg-lightGray', 'w-fit', 'rounded', 'p-2', 'my-2')
5868
elem.appendChild(e);

sogs/templates/view_room.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
<pre class="text-sm break-all whitespace-normal">{{room.url}}</pre>
1212
</div>
1313
<div class="w-1/3 lg:w-auto ">
14-
<img class="aspect-square max-w-full max-h-40 min-h-fit" src="invite.png" />
14+
<img class="aspect-square max-w-full max-h-40 " src="invite.png" />
1515
</div>
1616
</div>
1717

1818
<div class="flex">
1919
{% if show_recent %}
20-
<div id="messages-container" class=" overflow-y-auto border-2 rounded border-sessionGreen h-96 flex-1 my-5" >
20+
<div id="messages-container" class=" overflow-y-auto border-2 rounded border-sessionGreen h-96 flex flex-col-reverse my-5 w-full" >
2121
<ul id="messages" class="m-2">
2222
<li>loading...</li>
2323
</ul>

0 commit comments

Comments
 (0)