Skip to content

Commit

Permalink
fix: initialize mastodon worker status successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankLi123 committed Sep 29, 2024
1 parent a4ea181 commit b00e388
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions internal/node/component/info/handler_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,21 @@ func (c *Component) GetWorkersStatus(ctx echo.Context) error {
}
case c.config.Component.Federated != nil:
federatedComponent := c.config.Component.Federated[0]
// switch federatedComponent.Worker {
// case decentralized.Mastodon:
// response = &WorkerResponse{
// Data: ComponentInfo{
// RSS: &WorkerInfo{
// WorkerID: federatedComponent.ID,
// Network: federatedComponent.Network,
// Worker: federatedComponent.Worker,
// Tags: decentralized.ToTagsMap[decentralized.Mastodon],
// Platform: decentralized.PlatformMastodon,
// Status: worker.StatusReady},
// },
// }
// default:
// return nil
// }
response = &WorkerResponse{
Data: ComponentInfo{
RSS: &WorkerInfo{
WorkerID: federatedComponent.ID,
Network: federatedComponent.Network,
Worker: federatedComponent.Worker,
Tags: decentralized.ToTagsMap[decentralized.Mastodon],
Platform: decentralized.PlatformMastodon,
Status: worker.StatusReady},
},
switch federatedComponent.Worker {
case decentralized.Mastodon:
response = &WorkerResponse{
Data: ComponentInfo{
RSS: &WorkerInfo{
WorkerID: federatedComponent.ID,
Network: federatedComponent.Network,
Worker: federatedComponent.Worker,
Tags: decentralized.ToTagsMap[decentralized.Mastodon],
Platform: decentralized.PlatformMastodon,
Status: worker.StatusReady},
},
}
default:
return nil
}
default:
return nil
Expand Down Expand Up @@ -166,6 +155,19 @@ func (c *Component) fetchWorkerInfo(ctx context.Context, module *config.Module)
Status: worker.StatusUnknown,
}
}

// Federated worker cases
if module.Worker == decentralized.Mastodon {
return &WorkerInfo{
WorkerID: module.ID,
Network: module.Network,
Worker: module.Worker,
Tags: decentralized.ToTagsMap[decentralized.Mastodon],
Platform: decentralized.PlatformMastodon,
Status: worker.StatusReady,
}
}

// Fetch status and progress from a specific worker by id.
status, workerProgress := c.getWorkerStatusAndProgressByID(ctx, module.ID)

Expand Down Expand Up @@ -199,10 +201,6 @@ func (c *Component) fetchWorkerInfo(ctx context.Context, module *config.Module)
}
}

if module.Worker == decentralized.Mastodon {
workerInfo.Tags = []tag.Tag{tag.Social}
}

case network.RSSSource:
workerInfo.Tags = rss.ToTagsMap[module.Worker.(rss.Worker)]
}
Expand Down

0 comments on commit b00e388

Please sign in to comment.