Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package eventstream
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
eventprotocol "github.com/tutti-os/tutti/services/tuttid/api/events/generated"
|
|
userprojectbiz "github.com/tutti-os/tutti/services/tuttid/biz/userproject"
|
|
)
|
|
|
|
type UserProjectPublisher struct {
|
|
Service *Service
|
|
}
|
|
|
|
func (p UserProjectPublisher) PublishUserProjectUpdated(ctx context.Context, projects []userprojectbiz.Project) error {
|
|
if p.Service == nil {
|
|
return nil
|
|
}
|
|
|
|
generatedProjects := make([]eventprotocol.UserUserProject, 0, len(projects))
|
|
for _, project := range projects {
|
|
generatedProjects = append(generatedProjects, eventprotocol.UserUserProject{
|
|
Id: project.ID,
|
|
Path: project.Path,
|
|
Label: project.Label,
|
|
SectionKey: userprojectbiz.SectionKeyFromPath(project.Path),
|
|
CreatedAtUnixMs: project.CreatedAtUnixMS,
|
|
UpdatedAtUnixMs: project.UpdatedAtUnixMS,
|
|
LastUsedAtUnixMs: project.LastUsedAtUnixMS,
|
|
PinnedAtUnixMs: project.PinnedAtUnixMS,
|
|
})
|
|
}
|
|
|
|
payload, err := json.Marshal(eventprotocol.UserProjectUpdatedPayload{
|
|
Projects: generatedProjects,
|
|
})
|
|
if err != nil {
|
|
return fmt.Errorf("marshal user project updated payload: %w", err)
|
|
}
|
|
if err := p.Service.PublishFromServer(ctx, TopicUserProjectUpdated, payload); err != nil {
|
|
return fmt.Errorf("publish %s: %w", TopicUserProjectUpdated, err)
|
|
}
|
|
return nil
|
|
}
|