Send MARKREAD push notifications
Allows clients to dismiss notifications when another client marks the conversation as read.
This commit is contained in:
parent
7e21e79eab
commit
14cbd63412
@ -2004,6 +2004,8 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
|
|||||||
if err := uc.network.deleteChannel(ctx, upstreamName); err != nil {
|
if err := uc.network.deleteChannel(ctx, upstreamName); err != nil {
|
||||||
dc.logger.Printf("failed to delete channel %q: %v", upstreamName, err)
|
dc.logger.Printf("failed to delete channel %q: %v", upstreamName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uc.network.pushTargets.Del(upstreamName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "KICK":
|
case "KICK":
|
||||||
@ -2994,6 +2996,16 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if broadcast && network.pushTargets.Has(entity) {
|
||||||
|
// TODO: only broadcast if draft/read-marker has been negotiated
|
||||||
|
// TODO: use lower priority
|
||||||
|
network.pushTargets.Del(entity)
|
||||||
|
network.broadcastWebPush(ctx, &irc.Message{
|
||||||
|
Command: "MARKREAD",
|
||||||
|
Params: []string{entity, timestampStr},
|
||||||
|
})
|
||||||
|
}
|
||||||
case "SEARCH":
|
case "SEARCH":
|
||||||
store, ok := dc.user.msgStore.(msgstore.SearchStore)
|
store, ok := dc.user.msgStore.(msgstore.SearchStore)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
6
irc.go
6
irc.go
@ -464,6 +464,12 @@ func (cm *monitorCasemapMap) ForEach(f func(name string, online bool)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type casemapSet struct{ casemapMap }
|
||||||
|
|
||||||
|
func (cs *casemapSet) Add(name string) {
|
||||||
|
cs.set(name, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func isWordBoundary(r rune) bool {
|
func isWordBoundary(r rune) bool {
|
||||||
switch r {
|
switch r {
|
||||||
case '-', '_', '|': // inspired from weechat.look.highlight_regex
|
case '-', '_', '|': // inspired from weechat.look.highlight_regex
|
||||||
|
10
upstream.go
10
upstream.go
@ -522,21 +522,21 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
|||||||
self := uc.isOurNick(msg.Prefix.Name)
|
self := uc.isOurNick(msg.Prefix.Name)
|
||||||
|
|
||||||
ch := uc.network.channels.Get(bufferName)
|
ch := uc.network.channels.Get(bufferName)
|
||||||
|
highlight := false
|
||||||
if ch != nil && msg.Command != "TAGMSG" && !self {
|
if ch != nil && msg.Command != "TAGMSG" && !self {
|
||||||
if ch.Detached {
|
if ch.Detached {
|
||||||
uc.handleDetachedMessage(ctx, ch, msg)
|
uc.handleDetachedMessage(ctx, ch, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
highlight := uc.network.isHighlight(msg)
|
highlight = uc.network.isHighlight(msg)
|
||||||
if ch.DetachOn == database.FilterMessage || ch.DetachOn == database.FilterDefault || (ch.DetachOn == database.FilterHighlight && highlight) {
|
if ch.DetachOn == database.FilterMessage || ch.DetachOn == database.FilterDefault || (ch.DetachOn == database.FilterHighlight && highlight) {
|
||||||
uc.updateChannelAutoDetach(bufferName)
|
uc.updateChannelAutoDetach(bufferName)
|
||||||
}
|
}
|
||||||
if highlight {
|
|
||||||
uc.network.broadcastWebPush(ctx, msg)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ch == nil && uc.isOurNick(target) {
|
if highlight || uc.isOurNick(target) {
|
||||||
uc.network.broadcastWebPush(ctx, msg)
|
uc.network.broadcastWebPush(ctx, msg)
|
||||||
|
uc.network.pushTargets.Add(bufferName)
|
||||||
}
|
}
|
||||||
|
|
||||||
uc.produce(bufferName, msg, downstreamID)
|
uc.produce(bufferName, msg, downstreamID)
|
||||||
|
3
user.go
3
user.go
@ -134,6 +134,7 @@ type network struct {
|
|||||||
conn *upstreamConn
|
conn *upstreamConn
|
||||||
channels channelCasemapMap
|
channels channelCasemapMap
|
||||||
delivered deliveredStore
|
delivered deliveredStore
|
||||||
|
pushTargets casemapSet
|
||||||
lastError error
|
lastError error
|
||||||
casemap casemapping
|
casemap casemapping
|
||||||
}
|
}
|
||||||
@ -154,6 +155,7 @@ func newNetwork(user *user, record *database.Network, channels []database.Channe
|
|||||||
stopped: make(chan struct{}),
|
stopped: make(chan struct{}),
|
||||||
channels: m,
|
channels: m,
|
||||||
delivered: newDeliveredStore(),
|
delivered: newDeliveredStore(),
|
||||||
|
pushTargets: casemapSet{newCasemapMap()},
|
||||||
casemap: casemapRFC1459,
|
casemap: casemapRFC1459,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -377,6 +379,7 @@ func (net *network) updateCasemapping(newCasemap casemapping) {
|
|||||||
net.casemap = newCasemap
|
net.casemap = newCasemap
|
||||||
net.channels.SetCasemapping(newCasemap)
|
net.channels.SetCasemapping(newCasemap)
|
||||||
net.delivered.m.SetCasemapping(newCasemap)
|
net.delivered.m.SetCasemapping(newCasemap)
|
||||||
|
net.pushTargets.SetCasemapping(newCasemap)
|
||||||
if uc := net.conn; uc != nil {
|
if uc := net.conn; uc != nil {
|
||||||
uc.channels.SetCasemapping(newCasemap)
|
uc.channels.SetCasemapping(newCasemap)
|
||||||
uc.channels.ForEach(func(uch *upstreamChannel) {
|
uc.channels.ForEach(func(uch *upstreamChannel) {
|
||||||
|
Loading…
Reference in New Issue
Block a user