Support METADATA for users #54

Merged
emersion merged 1 commit from delthas/soju:fix-metadata-sub into master 2025-09-18 22:44:37 +02:00
Collaborator

Also, send METADATA messages on METADATA SUB, so that a client
can subscribe to keys after conn-reg.

We now send METADATA messages:

  • of joined channels, when forwarded
  • of all users, during welcome()
  • of all targets, when subscribing to a METADATA key
  • of a user, when adding them to our MONITOR list
  • of a MONITOR-ed user, when they become online again.

In order to avoid doing a linear amount of database requests for
fetching all MessageTargets, we now cache them. The memory impact
should be negligible.

Also, send METADATA messages on METADATA SUB, so that a client can subscribe to keys after conn-reg. We now send METADATA messages: - of joined channels, when forwarded - of all users, during welcome() - of all targets, when subscribing to a METADATA key - of a user, when adding them to our MONITOR list - of a MONITOR-ed user, when they become online again. In order to avoid doing a linear amount of database requests for fetching all MessageTargets, we now cache them. The memory impact should be negligible.
delthas force-pushed fix-metadata-sub from a980293a3d
All checks were successful
builds.sr.ht Job completed
to d2b0587743
All checks were successful
builds.sr.ht Job completed
2025-04-19 14:43:09 +02:00
Compare
delthas force-pushed fix-metadata-sub from d2b0587743
All checks were successful
builds.sr.ht Job completed
to 782082a396
All checks were successful
builds.sr.ht Job completed
2025-04-20 14:00:36 +02:00
Compare
delthas force-pushed fix-metadata-sub from 782082a396
All checks were successful
builds.sr.ht Job completed
to ba3f69d393
All checks were successful
builds.sr.ht Job completed
2025-04-20 14:03:13 +02:00
Compare
delthas changed title from WIP: Send METADATA messages on METADATA SUB after conn-reg to Support METADATA for users 2025-04-20 14:03:25 +02:00
Author
Collaborator

Now ready for review, works with emersion/goguma#18

Now ready for review, works with https://codeberg.org/emersion/goguma/pulls/18
Author
Collaborator

Gentle ping ❤️

Gentle ping ❤️
delthas force-pushed fix-metadata-sub from ba3f69d393
All checks were successful
builds.sr.ht Job completed
to 407019d247
All checks were successful
builds.sr.ht Job completed
2025-05-18 17:27:05 +02:00
Compare
Author
Collaborator

Rebased.

Rebased.
emersion force-pushed fix-metadata-sub from 407019d247
All checks were successful
builds.sr.ht Job completed
to cf87f7ecf3
All checks were successful
builds.sr.ht Job completed
2025-07-24 18:19:49 +02:00
Compare
Owner

This patch applies cleanly without #55. Rebased to drop that extraneous commit.

This patch applies cleanly without https://codeberg.org/emersion/soju/pulls/55. Rebased to drop that extraneous commit.
@ -61,3 +61,3 @@
GetMessageLastID(ctx context.Context, networkID int64, name string) (int64, error)
GetMessageTarget(ctx context.Context, networkID int64, target string) (*MessageTarget, error)
ListMessageTargets(ctx context.Context, networkID int64) ([]MessageTarget, error)
Owner

I'm worried about the performance implications of this function. We only ever append to the MessageTargets table without ever deleting from it.

I'm worried about the performance implications of this function. We only ever append to the `MessageTargets` table without ever deleting from it.
Author
Collaborator

This function would only be called when loading a network, and we'd cache its values afterwards.

This function would only be called when loading a network, and we'd cache its values afterwards.
Owner

Yeah, but this is an append-only list, so we'd load an increasingly long list on startup for each user.

Yeah, but this is an append-only list, so we'd load an increasingly long list on startup for each user.
Owner

I've pushed a fixup patch to stop keeping all message targets around in memory. Does that look fine to you?

I've pushed a fixup patch to stop keeping all message targets around in memory. Does that look fine to you?
emersion marked this conversation as resolved
downstream.go Outdated
@ -3521,0 +3528,4 @@
dc.forEachNetwork(func(net *network) {
// Technically we are only required to send the METADATA of channels we are joined to, and users
// we are sharing a channel with or are MONITOR-ing, but it is easier to send all METADATA we are
// aware of, and the spec guarantees that servers MAY send these messages at any time.
Owner

To avoid the performance issues mentioned above, I think it'd be safer to just send METADATA for channels and monitored nicks here. Same about welcome.

To avoid the performance issues mentioned above, I think it'd be safer to just send METADATA for channels and monitored nicks here. Same about `welcome`.
Author
Collaborator

We cannot do this because we need to send METADATA for "other clients in the channels they are joined to" https://ircv3.net/specs/extensions/metadata#notifications

Without a list, we'd need to query every single nick in common channels.

We cannot do this because we need to send METADATA for "other clients in the channels they are joined to" https://ircv3.net/specs/extensions/metadata#notifications Without a list, we'd need to query every single nick in common channels.
Owner

Ah, indeed!

I thought about iterating over user lists for all joined channels and monitored users, but it sounds like this would get quite complicated and inefficient.

I'm still not a fan of keeping state about all message targets. Do we really need to keep messageTargets around?

Ah, indeed! I thought about iterating over user lists for all joined channels and monitored users, but it sounds like this would get quite complicated and inefficient. I'm still not a fan of keeping state about all message targets. Do we really need to keep `messageTargets` around?
emersion marked this conversation as resolved
emersion force-pushed fix-metadata-sub from cf87f7ecf3
All checks were successful
builds.sr.ht Job completed
to 0fbb0d2fa3
All checks were successful
builds.sr.ht Job completed
2025-07-25 16:21:38 +02:00
Compare
upstream.go Outdated
@ -1693,6 +1693,9 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
Command: msg.Command,
Params: []string{dc.nick, target},
})
if online {
Owner

Is there a reason why we need the network to be online to send metadata?

Actually, sounds like we should send metadata in the downstream handler for MONITOR?

Is there a reason why we need the network to be online to send metadata? Actually, sounds like we should send metadata in the downstream handler for `MONITOR`?
Owner

It sounds like we already send meatadata in the downstream MONITOR handler.

It sounds like we already send meatadata in the downstream `MONITOR` handler.
emersion marked this conversation as resolved
downstream.go Outdated
@ -2692,0 +2712,4 @@
}}
}
dc.sendTargetMetadata(ctx, mt)
}
Author
Collaborator

No need to send METADATA on MONITOR + if we already sent that info on welcome?

No need to send METADATA on MONITOR + if we already sent that info on welcome?
emersion marked this conversation as resolved
upstream.go Outdated
@ -1696,0 +1696,4 @@
// TODO
//if online {
// dc.sendTargetMetadata(ctx, target)
//}
Author
Collaborator

OK, can remove this

OK, can remove this
emersion marked this conversation as resolved
emersion force-pushed fix-metadata-sub from 168ab01b33
All checks were successful
builds.sr.ht Job completed
to 6f9d7cb2a5
All checks were successful
builds.sr.ht Job completed
2025-09-18 17:43:38 +02:00
Compare
Owner

I've addressed these comments. Please test!

I've addressed these comments. Please test!
Author
Collaborator

@emersion Tested, LGTM. Let's merge! 😁

@emersion Tested, LGTM. Let's merge! 😁
emersion merged commit 6f9d7cb2a5 into master 2025-09-18 22:44:37 +02:00
Owner

Thank you!

Thank you!
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!54
No description provided.