Partially implement reply feature in iOS

#28
This commit is contained in:
KnugiHK
2023-06-02 01:27:05 +08:00
parent 7c78cce221
commit 80c3ed11f6
2 changed files with 30 additions and 7 deletions

View File

@@ -2,6 +2,7 @@
import sqlite3 import sqlite3
import json import json
import string
import jinja2 import jinja2
import os import os
import shutil import shutil
@@ -35,10 +36,14 @@ def messages(db, data):
ZMESSAGEDATE, ZMESSAGEDATE,
ZTEXT, ZTEXT,
ZMESSAGETYPE, ZMESSAGETYPE,
ZWAGROUPMEMBER.ZMEMBERJID ZWAGROUPMEMBER.ZMEMBERJID,
FROM main.ZWAMESSAGE ZMETADATA,
LEFT JOIN main.ZWAGROUPMEMBER ZSTANZAID
ON main.ZWAMESSAGE.ZGROUPMEMBER = main.ZWAGROUPMEMBER.Z_PK;""") FROM ZWAMESSAGE
LEFT JOIN ZWAGROUPMEMBER
ON ZWAMESSAGE.ZGROUPMEMBER = ZWAGROUPMEMBER.Z_PK
LEFT JOIN ZWAMEDIAITEM
ON ZWAMESSAGE.Z_PK = ZWAMEDIAITEM.ZMESSAGE;""")
i = 0 i = 0
content = c.fetchone() content = c.fetchone()
while content is not None: while content is not None:
@@ -53,7 +58,8 @@ def messages(db, data):
"reply": None, "reply": None,
"caption": None, "caption": None,
"meta": False, "meta": False,
"data": None "data": None,
"key_id": content["ZSTANZAID"][:17]
} }
if "-" in content[0] and content[2] == 0: if "-" in content[0] and content[2] == 0:
name = None name = None
@@ -89,6 +95,11 @@ def messages(db, data):
data[content[0]]["messages"][content[1]]["data"] = None data[content[0]]["messages"][content[1]]["data"] = None
else: else:
# real message # real message
if content["ZMETADATA"] is not None and content["ZMETADATA"].startswith(b"\x2a\x14"):
quoted = content["ZMETADATA"][2:19]
data[content[0]]["messages"][content[1]]["reply"] = quoted.decode()
data[content[0]]["messages"][content[1]]["quoted_data"] = None # TODO
if content[2] == 1: if content[2] == 1:
if content[5] == 14: if content[5] == 14:
msg = "Message deleted" msg = "Message deleted"

View File

@@ -68,7 +68,13 @@
{% if msg.reply is not none %} {% if msg.reply is not none %}
<div class="reply"> <div class="reply">
<span style="color: #70777a;">Replying to </span> <span style="color: #70777a;">Replying to </span>
<a href="#{{msg.reply}}" style="color: #168acc;">"{{ msg.quoted_data or 'media' }}"</a> <a href="#{{msg.reply}}" style="color: #168acc;">
{% if msg.quoted_data is not none %}
"{{msg.quoted_data}}"
{% else %}
this message
{% endif %}
</a>
</div> </div>
{% endif %} {% endif %}
{% if msg.meta == true or msg.media == false and msg.data is none %} {% if msg.meta == true or msg.media == false and msg.data is none %}
@@ -124,7 +130,13 @@
{% if msg.reply is not none %} {% if msg.reply is not none %}
<div class="reply"> <div class="reply">
<span style="color: #70777a;">Replying to </span> <span style="color: #70777a;">Replying to </span>
<a href="#{{msg.reply}}" style="color: #168acc;">"{{ msg.quoted_data or 'media' }}"</a> <a href="#{{msg.reply}}" style="color: #168acc;">
{% if msg.quoted_data is not none %}
"{{msg.quoted_data}}"
{% else %}
this message
{% endif %}
</a>
</div> </div>
{% endif %} {% endif %}
{% if msg.meta == true or msg.media == false and msg.data is none %} {% if msg.meta == true or msg.media == false and msg.data is none %}