7
123
Fork
You've already forked soju
35

Introduce METADATA soju.im/alert #73

Open
amk wants to merge 1 commit from amk/soju:metadata-alert into master
pull from: amk/soju:metadata-alert
merge into: emersion:master
emersion:master
emersion:v0.10
emersion:webpush-state
emersion:feature-introspection-username
emersion:v0.6
emersion:v0.2
First-time contributor
Copy link

This introduces a new metadata option that when set by a user will
inform the client that all messages sent on that buffer should display
a notification to the user.

This introduces a new metadata option that when set by a user will inform the client that all messages sent on that buffer should display a notification to the user.
amk force-pushed metadata-alert from e3eba066e8
All checks were successful
builds.sr.ht Job completed
to 624550e758
All checks were successful
builds.sr.ht Job completed
2025年10月20日 13:39:36 +02:00
Compare
First-time contributor
Copy link

related https://todo.sr.ht/~emersion/soju/107

at least for the usecase of always receiving notifications for some channels

related https://todo.sr.ht/~emersion/soju/107 at least for the usecase of always receiving notifications for some channels
amk force-pushed metadata-alert from 624550e758
All checks were successful
builds.sr.ht Job completed
to 337271305f
All checks were successful
builds.sr.ht Job completed
2025年10月21日 11:20:24 +02:00
Compare
upstream.go Outdated
@ -693,12 +694,20 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
uc.updateChannelAutoDetach(bufferName)
}
cmt,err:=uc.srv.db.GetMessageTarget(ctx,uc.network.ID,ch.Name)
Author
First-time contributor
Copy link

Should the alert db field go on the Channel table instead to avoid this extra lookup? I put it there as it seemed most similar to Muted/Pinned but the later message target lookup is done on the user who sent the message and I want this feature to make it so all messages to a channel with this set cause a notification rather than specific users

Should the `alert` db field go on the `Channel` table instead to avoid this extra lookup? I put it there as it seemed most similar to Muted/Pinned but the later message target lookup is done on the user who sent the message and I want this feature to make it so all messages to a channel with this set cause a notification rather than specific users
Owner
Copy link

Right: soju.im/alert=1 wouldn't make sense for users since that's already the default. One could argue that soju.im/alert=0 on a user should stop notifying each time a message is sent, but we already have soju.im/muted for this.

tl;dr I agree it would make more sense to have in Channel.

Right: `soju.im/alert=1` wouldn't make sense for users since that's already the default. One could argue that `soju.im/alert=0` on a user should stop notifying each time a message is sent, but we already have `soju.im/muted` for this. tl;dr I agree it would make more sense to have in `Channel`.
amk changed title from (削除) WIP: Introduce METADATA soju.im/alert (削除ここまで) to Introduce METADATA soju.im/alert 2025年10月21日 11:24:50 +02:00
amk force-pushed metadata-alert from 337271305f
All checks were successful
builds.sr.ht Job completed
to 96f5177a2d
All checks were successful
builds.sr.ht Job completed
2025年10月21日 11:50:36 +02:00
Compare

How does this interact with:

  • soju.im/muted: it seems a bit weird to set a channel as muted and to ask to be notified each time a message is sent. Not sure we want to add dependencies between metadata keys though...
  • The existing -relay-detached=message setting for channels? It sounds pretty similar? I'm not sure we want to introduce two knobs for the same thing.
  • Instead of a boolean, would it make more sense to add a tri-state, e.g. soju.im/notify=none|highlight|message? Hm, but still wouldn't let us get rid of soju.im/muted or else we'd break existing clients... (Also as discussed above not sure all values make sense for users...)
How does this interact with: - `soju.im/muted`: it seems a bit weird to set a channel as muted _and_ to ask to be notified each time a message is sent. Not sure we want to add dependencies between metadata keys though... - The existing `-relay-detached=message` setting for channels? It sounds pretty similar? I'm not sure we want to introduce two knobs for the same thing. - Instead of a boolean, would it make more sense to add a tri-state, e.g. `soju.im/notify=none|highlight|message`? Hm, but still wouldn't let us get rid of `soju.im/muted` or else we'd break existing clients... (Also as discussed above not sure all values make sense for users...)
Author
First-time contributor
Copy link

@emersion wrote in #73 (comment):

How does this interact with:

* `soju.im/muted`: it seems a bit weird to set a channel as muted _and_ to ask to be notified each time a message is sent. Not sure we want to add dependencies between metadata keys though...

Yeah I thought about this, as it stands muting a channel will take precedence and notifications wont come through which I think is as one would expect. Having soju toggle muted when alert is set and vice versa and broadcast the METADATA SET for the automatically toggled entry might be an okay solution, but I'm not sure if that's a good behavior

* The existing `-relay-detached=message` setting for channels? It sounds pretty similar? I'm not sure we want to introduce two knobs for the same thing.

I'm not sure how this works, does it basically operate as BouncerServ sending a DM that there was a message in channel x? I think that does have some overlap but with this it does make it easier to build UI and also not require setting channels as detached, I havent used that feature of soju though so dont know much about it.

* Instead of a boolean, would it make more sense to add a tri-state, e.g. `soju.im/notify=none|highlight|message`? Hm, but still wouldn't let us get rid of `soju.im/muted` or else we'd break existing clients... (Also as discussed above not sure all values make sense for users...)

Yeah I think this would be ideal but the process of migration seems like itd be fairly painful. We could keep soju.im/muted and have it exist as a deprecated front for soju.im/notify maybe?

@emersion wrote in https://codeberg.org/emersion/soju/pulls/73#issuecomment-7873721: > How does this interact with: > > * `soju.im/muted`: it seems a bit weird to set a channel as muted _and_ to ask to be notified each time a message is sent. Not sure we want to add dependencies between metadata keys though... Yeah I thought about this, as it stands muting a channel will take precedence and notifications wont come through which I think is as one would expect. Having soju toggle muted when alert is set and vice versa and broadcast the METADATA SET for the automatically toggled entry might be an okay solution, but I'm not sure if that's a good behavior > > * The existing `-relay-detached=message` setting for channels? It sounds pretty similar? I'm not sure we want to introduce two knobs for the same thing. I'm not sure how this works, does it basically operate as BouncerServ sending a DM that there was a message in channel x? I think that does have some overlap but with this it does make it easier to build UI and also not require setting channels as detached, I havent used that feature of soju though so dont know much about it. > * Instead of a boolean, would it make more sense to add a tri-state, e.g. `soju.im/notify=none|highlight|message`? Hm, but still wouldn't let us get rid of `soju.im/muted` or else we'd break existing clients... (Also as discussed above not sure all values make sense for users...) Yeah I think this would be ideal but the process of migration seems like itd be fairly painful. We could keep `soju.im/muted` and have it exist as a deprecated front for `soju.im/notify` maybe?

Having soju toggle muted when alert is set and vice versa and broadcast the METADATA SET for the automatically toggled entry might be an okay solution, but I'm not sure if that's a good behavior

Yeah, it's a bit annoying to implement. (If we go for soju.im/notify, we'd need to do something similar.)

does it basically operate as BouncerServ sending a DM that there was a message in channel x?

Detached channels are hidden from clients but still joined. Enabling -relay-detached=message means that the user is interested in being notified about all messages in the channel, which results in BouncerServ relaying these messages. I think we could have a single setting notify=none|highlight|message which works when the channel is attached and when it's detached, instead of two separate knobs. I'm not suggesting that we re-use that setting as-is, I'm suggesting that we could generalize it for attached channels.

Yeah I think this would be ideal but the process of migration seems like itd be fairly painful. We could keep soju.im/muted and have it exist as a deprecated front for soju.im/notify maybe?

Yeah, with some work (as hinted above), it can be a solution I think.

If we make this new setting a channel thing DB-wise, then we'd need to store the metadata value differently depending on whether it's a channel vs user.

> Having soju toggle muted when alert is set and vice versa and broadcast the METADATA SET for the automatically toggled entry might be an okay solution, but I'm not sure if that's a good behavior Yeah, it's a bit annoying to implement. (If we go for `soju.im/notify`, we'd need to do something similar.) > does it basically operate as BouncerServ sending a DM that there was a message in channel x? Detached channels are hidden from clients but still joined. Enabling `-relay-detached=message` means that the user is interested in being notified about all messages in the channel, which results in BouncerServ relaying these messages. I think we could have a single setting `notify=none|highlight|message` which works when the channel is attached and when it's detached, instead of two separate knobs. I'm not suggesting that we re-use that setting as-is, I'm suggesting that we could generalize it for attached channels. > Yeah I think this would be ideal but the process of migration seems like itd be fairly painful. We could keep soju.im/muted and have it exist as a deprecated front for soju.im/notify maybe? Yeah, with some work (as hinted above), it can be a solution I think. If we make this new setting a channel thing DB-wise, then we'd need to store the metadata value differently depending on whether it's a channel vs user.
Author
First-time contributor
Copy link

Okay I think this all make sense to me, the plan I'll go for is to

  • add a column to MessageTarget called notify that uses the existing MessageFilter semantics
  • Maybe rename the relay_detached column and usage to be notify for consistency?
  • migrate the muted column to use the new notify column in MessageTarget as well as migrating the existing values to the relay_detached column in Channels
  • keep current relay_detached behavior on detached channels, for attached channels send notifications as configured
  • when listing metadata include notify metadata retrieved from Channels in addition to MessageTarget
  • For clients subscribed soju.im/muted set it to true only if notify is set to None, when modifying muted send metadata notifications to clients subscribed to soju.im/notify that its been updated
Okay I think this all make sense to me, the plan I'll go for is to - add a column to `MessageTarget` called notify that uses the existing `MessageFilter` semantics - Maybe rename the relay_detached column and usage to be notify for consistency? - migrate the `muted` column to use the new `notify` column in `MessageTarget` as well as migrating the existing values to the `relay_detached` column in `Channels` - keep current `relay_detached` behavior on detached channels, for attached channels send notifications as configured - when listing metadata include notify metadata retrieved from Channels in addition to MessageTarget - For clients subscribed `soju.im/muted` set it to true only if `notify` is set to None, when modifying muted send metadata notifications to clients subscribed to `soju.im/notify` that its been updated
All checks were successful
builds.sr.ht Job completed
Required
Details
This pull request has changes conflicting with the target branch.
  • database/postgres_migrations.go
  • database/sqlite_migrations.go
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u metadata-alert:amk-metadata-alert
git switch amk-metadata-alert
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
emersion/soju!73
Reference in a new issue
emersion/soju
No description provided.
Delete branch "amk/soju:metadata-alert"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?