fix(mail): resolve beads-native queues/channels by name
resolveByName() only checked config-based queues/channels, missing beads-native ones (gt:queue, gt:channel). Added lookup for both. Also added LookupQueueByName to beads package for parity with LookupChannelByName. Fixes: gt-l5qbi3 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -292,6 +292,37 @@ func (b *Beads) DeleteQueueBead(id string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LookupQueueByName finds a queue by its name field (not by ID).
|
||||||
|
// This is used for address resolution where we may not know the full bead ID.
|
||||||
|
func (b *Beads) LookupQueueByName(name string) (*Issue, *QueueFields, error) {
|
||||||
|
// First try direct lookup by standard ID formats (town and rig level)
|
||||||
|
for _, isTownLevel := range []bool{true, false} {
|
||||||
|
id := QueueBeadID(name, isTownLevel)
|
||||||
|
issue, fields, err := b.GetQueueBead(id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
if issue != nil {
|
||||||
|
return issue, fields, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not found by ID, search all queues by name field
|
||||||
|
queues, err := b.ListQueueBeads()
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, issue := range queues {
|
||||||
|
fields := ParseQueueFields(issue.Description)
|
||||||
|
if fields.Name == name {
|
||||||
|
return issue, fields, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil, nil // Not found
|
||||||
|
}
|
||||||
|
|
||||||
// MatchClaimPattern checks if an identity matches a claim pattern.
|
// MatchClaimPattern checks if an identity matches a claim pattern.
|
||||||
// Patterns support:
|
// Patterns support:
|
||||||
// - "*" matches anyone
|
// - "*" matches anyone
|
||||||
|
|||||||
@@ -171,7 +171,29 @@ func (r *Resolver) resolveByName(name string) ([]Recipient, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for queue in config
|
// Check for beads-native queue
|
||||||
|
if r.beads != nil {
|
||||||
|
_, queueFields, err := r.beads.LookupQueueByName(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if queueFields != nil {
|
||||||
|
foundQueue = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for beads-native channel
|
||||||
|
if r.beads != nil {
|
||||||
|
_, channelFields, err := r.beads.LookupChannelByName(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if channelFields != nil {
|
||||||
|
foundChannel = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for queue/channel in config (legacy)
|
||||||
if r.townRoot != "" {
|
if r.townRoot != "" {
|
||||||
cfg, err := config.LoadMessagingConfig(config.MessagingConfigPath(r.townRoot))
|
cfg, err := config.LoadMessagingConfig(config.MessagingConfigPath(r.townRoot))
|
||||||
if err == nil && cfg != nil {
|
if err == nil && cfg != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user