Skip to content

Commit

Permalink
fix: modify id type
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Sep 25, 2024
1 parent ca6ccaf commit e7c9a59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions internal/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func (h *Handler) EnablePorter(ctx context.Context, req *porter.EnablePorterRequ
*porter.EnablePorterResponse, error) {
var contextIds []*librarian.InternalID
h.clientMap.Range(func(key, value interface{}) bool {
id, ok := key.(*librarian.InternalID)
id, ok := key.(int64)
if !ok {
return true
}
contextIds = append(contextIds, id)
contextIds = append(contextIds, &librarian.InternalID{Id: id})
return true
})
return &porter.EnablePorterResponse{
Expand All @@ -50,15 +50,15 @@ func (h *Handler) EnableContext(ctx context.Context, req *porter.EnableContextRe
var config PorterContext
err := json.Unmarshal([]byte(req.GetContextJson()), &config)
if err != nil {
return nil, errors.BadRequest("invalid context_json", "")
return nil, errors.BadRequest("invalid context_json", err.Error())
}
h.clientMap.Store(req.GetContextId(), config)
h.clientMap.Store(req.GetContextId().GetId(), config)
return &porter.EnableContextResponse{}, nil
}

func (h *Handler) DisableContext(ctx context.Context, req *porter.DisableContextRequest) (
*porter.DisableContextResponse, error) {
h.clientMap.Delete(req.GetContextId())
h.clientMap.Delete(req.GetContextId().GetId())
return &porter.DisableContextResponse{}, nil
}

Expand All @@ -67,9 +67,9 @@ func (h *Handler) PushFeedItems(ctx context.Context, req *porter.PushFeedItemsRe
var config PushFeedItems
err := json.Unmarshal([]byte(req.GetDestination().GetConfigJson()), &config)
if err != nil {
return nil, errors.BadRequest("invalid config_json", "")
return nil, errors.BadRequest("invalid config_json", err.Error())
}
clientAny, ok := h.clientMap.Load(req.GetDestination().GetContextId())
clientAny, ok := h.clientMap.Load(req.GetDestination().GetContextId().GetId())
if !ok {
return nil, errors.BadRequest("context not found", "")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ type PorterContext struct {
}

type PushFeedItems struct {
ChannelID int64 `json:"channel_id" jsonschema:"title=Channel ID"`
ChannelID int64 `json:"channel_id,string" jsonschema:"title=Channel ID"`
}

0 comments on commit e7c9a59

Please sign in to comment.