[PATCH v4] Support @+draft/channel-context
Export this patch
---
Addresses comments in v3 ;-)
lib/client_controller.dart | 16 +++++++++++-----
lib/push.dart | 8 +++++++-
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/lib/client_controller.dart b/lib/client_controller.dart
index 72f3e4c..1223b1a 100644
--- a/lib/client_controller.dart
+++ b/lib/client_controller.dart
@@ -576,7 +576,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) && _bufferList.get(channel, network) != null) {
+ target = channel;
+ } else {
+ target = msg.source.name;
+ }
}
if (msg.cmd == 'TAGMSG') {
var typing = msg.tags['+typing'];
@@ -828,31 +833,32 @@ class ClientController {
if (buffer.muted) {
return;
}
+ var isChannel = client.isChannel(buffer.name);
entries = entries.where((entry) {
if (buffer.lastDeliveredTime != null && buffer.lastDeliveredTime!.compareTo(entry.time) >= 0) {
return false;
}
- return _shouldNotifyMessage(entry);
+ return _shouldNotifyMessage(isChannel, entry);
}).toList();
if (entries.isEmpty) {
return;
}
- if (client.isChannel(buffer.name)) {
+ if (isChannel) {
await _notifController.showHighlight(entries, buffer);
} else {
await _notifController.showDirectMessage(entries, 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;
diff --git a/lib/push.dart b/lib/push.dart
index 4983f85..dc03e65 100644
--- a/lib/push.dart
+++ b/lib/push.dart
@@ -69,7 +69,13 @@ Future<void> handlePushMessage(DB db, WebPushSubscriptionEntry sub, List<int> ci
var target = msg.params[0];
var isChannel = target.length > 0 && networkEntry.isupport.chanTypes.contains(target[0]);
if (!isChannel) {
- target = msg.source!.name;
+ var channel = msg.tags['+draft/channel-context'];
+ if (channel != null && channel.length > 0 && networkEntry.isupport.chanTypes.contains(channel[0]) && await _fetchBuffer(db, channel, networkEntry) != null) {
+ target = channel;
+ isChannel = true;
+ } else {
+ target = msg.source!.name;
+ }
}
var bufferEntry = await _fetchBuffer(db, target, networkEntry);
base-commit: eec6ded05f98978894ce7f3d10fc42aeb19ad64a
--
2.17.1
Pushed with some minor changes and a UI update. Thanks!