~emersion/goguma-dev

Support @+draft/channel-context v2 SUPERSEDED

delthas: 1
 Support @+draft/channel-context

 1 files changed, 12 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/goguma-dev/patches/31640/mbox | git am -3
Learn more about email & git

[PATCH v2] Support @+draft/channel-context Export this patch

This tag enables bots to specify the particular channel context the
message is related to.

See: https://todo.sr.ht/~emersion/goguma/80
See: https://github.com/ircv3/ircv3-specifications/issues/497
See: https://github.com/ircv3/ircv3-specifications/pull/498
---
 lib/client_controller.dart | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/client_controller.dart b/lib/client_controller.dart
index 417f72b..bf56dac 100644
--- a/lib/client_controller.dart
+++ b/lib/client_controller.dart
@@ -491,7 +491,12 @@ class ClientController {
			// target can be my own nick for direct messages, "*" for server
			// messages, "$xxx" for server-wide broadcasts
			if (!client.isChannel(target) && !client.isMyNick(msg.source.name)) {
				target = msg.source.name;
				var channel = msg.tags['+draft/channel-context'];
				if(channel != null && client.isChannel(channel)) {
					target = channel;
				} else {
					target = msg.source.name;
				}
			}
			return _handleChatMessages(target, [msg]);
		case 'INVITE':
@@ -669,38 +674,39 @@ class ClientController {
		if (buffer.muted) {
			return;
		}
		var isChannel = client.isChannel(buffer.name);
		var needsNotification = entries.any((entry) {
			if (buffer.lastDeliveredTime != null && buffer.lastDeliveredTime!.compareTo(entry.time) >= 0) {
				return false;
			}
			return _shouldNotifyMessage(entry);
			return _shouldNotifyMessage(isChannel, entry);
		});
		if (!needsNotification) {
			return;
		}

		var unread = await _db.listUnreadMessages(buffer.id);
		var notifyEntries = unread.where(_shouldNotifyMessage).toList();
		var notifyEntries = unread.where((entry) => _shouldNotifyMessage(isChannel, entry)).toList();

		if (notifyEntries.isEmpty) {
			return;
		}

		if (client.isChannel(buffer.name)) {
		if (isChannel) {
			await _notifController.showHighlight(notifyEntries, buffer);
		} else {
			await _notifController.showDirectMessage(notifyEntries, buffer);
		}
	}

	bool _shouldNotifyMessage(MessageEntry entry) {
	bool _shouldNotifyMessage(bool isChannel, MessageEntry entry) {
		if (entry.msg.cmd != 'PRIVMSG' && entry.msg.cmd != 'NOTICE') {
			return false;
		}
		if (client.isMyNick(entry.msg.source!.name)) {
			return false;
		}
		if (client.isChannel(entry.msg.params[0]) && !findTextHighlight(entry.msg.params[1], client.nick)) {
		if (isChannel && !findTextHighlight(entry.msg.params[1], client.nick)) {
			return false;
		}
		return true;

base-commit: 10a2a3232f0dbb959d17500cc75830f8b60b8257
-- 
2.17.1
Needs an update for Firebase.