Compare commits

...

2 Commits

6 changed files with 86 additions and 20 deletions

View File

@ -197,6 +197,7 @@ Future<void> entrypoint() async {
CryptographicHashManager(),
DelayedDeliveryManager(),
MessageRetractionManager(),
LastMessageCorrectionManager(),
])
..registerFeatureNegotiators([
ResourceBindingNegotiator(),

View File

@ -902,6 +902,46 @@ class XmppService {
// that mean that the message could not be delivered.
sendEvent(MessageUpdatedEvent(message: newMsg));
}
Future<void> _handleMessageCorrection(MessageEvent event, String conversationJid) async {
final ms = GetIt.I.get<MessageService>();
final cs = GetIt.I.get<ConversationService>();
final msg = await ms.getMessageByStanzaId(conversationJid, event.messageCorrectionId!);
if (msg == null) {
_log.warning('Received message correction for message ${event.messageCorrectionId} we cannot find.');
return;
}
// Check if the Jid is allowed to do correct the message
// TODO(Unknown): Maybe use the JID parser?
final bareSender = event.fromJid.toBare().toString();
if (msg.sender.split('/').first != bareSender) {
_log.warning('Received a message correction from $bareSender for message that is not sent by $bareSender');
return;
}
// Check if the message can be corrected
if (!msg.canEdit(true)) {
_log.warning('Received a message correction for a message that cannot be edited');
return;
}
final newMsg = await ms.updateMessage(
msg.id,
body: event.body,
isEdited: true,
);
sendEvent(MessageUpdatedEvent(message: newMsg));
final conv = await cs.getConversationByJid(msg.conversationJid);
if (conv != null && conv.lastMessage?.id == msg.id) {
final newConv = conv.copyWith(
lastMessage: newMsg,
);
cs.setConversation(newConv);
sendEvent(ConversationUpdatedEvent(conversation: newConv));
}
}
Future<void> _onMessage(MessageEvent event, { dynamic extra }) async {
// The jid this message event is meant for
@ -918,6 +958,12 @@ class XmppService {
// Process the chat state update. Can also be attached to other messages
if (event.chatState != null) await _onChatState(event.chatState!, conversationJid);
// Process message corrections separately
if (event.messageCorrectionId != null) {
await _handleMessageCorrection(event, conversationJid);
return;
}
// Process File Upload Notifications replacements separately
if (event.funReplacement != null) {
await _handleFileUploadNotificationReplacement(event, conversationJid);

View File

@ -112,19 +112,37 @@ class ConversationsListRowState extends State<ConversationsListRow> {
);
}
Widget _getLastMessageIcon() {
Widget _getLastMessageIcon(bool sentBySelf) {
final lastMessage = widget.conversation.lastMessage;
if (lastMessage == null) return const SizedBox();
if (lastMessage.displayed) {
return Icon(
Icons.done_all,
color: Colors.blue.shade700,
);
} else if (lastMessage.received) {
return const Icon(Icons.done_all);
} else if (lastMessage.acked) {
return const Icon(Icons.done);
Widget? icon;
if (sentBySelf) {
if (lastMessage.displayed) {
icon = Icon(
Icons.done_all,
color: Colors.blue.shade700,
);
} else if (lastMessage.received) {
icon = const Icon(Icons.done_all);
} else if (lastMessage.acked) {
icon = const Icon(Icons.done);
}
} else {
if (lastMessage.isEdited) {
icon = const Icon(Icons.edit);
}
}
if (icon != null) {
if (widget.conversation.unreadCounter > 0) {
return Padding(
padding: const EdgeInsets.only(right: 5),
child: icon,
);
} else {
return icon;
}
}
return const SizedBox();
@ -214,6 +232,9 @@ class ConversationsListRowState extends State<ConversationsListRow> {
child: _buildLastMessageBody(),
),
const Spacer(),
_getLastMessageIcon(sentBySelf),
Visibility(
visible: showBadge,
child: Badge(
@ -221,10 +242,6 @@ class ConversationsListRowState extends State<ConversationsListRow> {
badgeColor: bubbleColorSent,
),
),
Visibility(
visible: sentBySelf,
child: _getLastMessageIcon(),
),
],
),
),

View File

@ -133,8 +133,7 @@
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0308.html" />
<xmpp:status>partial</xmpp:status>
<xmpp:note xml:lang="en">Supports only sending corrections</xmpp:note>
<xmpp:status>complete</xmpp:status>
<xmpp:version>1.2.1</xmpp:version>
</xmpp:SupportedXep>
</implements>

View File

@ -718,14 +718,14 @@ packages:
name: moxxmpp
url: "https://git.polynom.me/api/packages/Moxxy/pub/"
source: hosted
version: "0.1.6"
version: "0.1.6+1"
moxxmpp_socket_tcp:
dependency: "direct main"
description:
name: moxxmpp_socket_tcp
url: "https://git.polynom.me/api/packages/Moxxy/pub/"
source: hosted
version: "0.1.2+8"
version: "0.1.2+9"
moxxyv2_builders:
dependency: "direct main"
description:

View File

@ -59,10 +59,10 @@ dependencies:
version: 0.1.15
moxxmpp:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.6
version: 0.1.6+1
moxxmpp_socket_tcp:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.2+8
version: 0.1.2+9
moxxyv2_builders:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.0
@ -128,6 +128,9 @@ dependency_overrides:
git:
url: https://codeberg.org/PapaTutuWawa/omemo_dart.git
rev: c68471349ab1b347ec9ad54651265710842c50b7
# NOTE: Leave here for development purposes
#moxxmpp:
# path: ../moxxmpp/packages/moxxmpp
extra_licenses:
- name: undraw.co