(nodeIDs []string)
| 534 | } |
| 535 | |
| 536 | func (h *Handler) ApplyNodes(nodeIDs []string) { |
| 537 | for _, nodeID := range nodeIDs { |
| 538 | go func(id string) { |
| 539 | client, err := h.dial(id) |
| 540 | if err != nil { |
| 541 | log.Printf("applyNodes: dial %s: %v", id, err) |
| 542 | return |
| 543 | } |
| 544 | nodeInbounds, err := h.ibStore.ListInboundsByNode(id) |
| 545 | if err != nil { |
| 546 | log.Printf("applyNodes: list inbounds %s: %v", id, err) |
| 547 | return |
| 548 | } |
| 549 | userAccesses, err := h.userStore.ListUserInboundsByNode(id) |
| 550 | if err != nil { |
| 551 | log.Printf("applyNodes: list user accesses %s: %v", id, err) |
| 552 | return |
| 553 | } |
| 554 | userIDs := collectUserIDs(userAccesses) |
| 555 | userMap, err := h.userStore.GetUsersByIDs(userIDs) |
| 556 | if err != nil { |
| 557 | log.Printf("applyNodes: get users %s: %v", id, err) |
| 558 | return |
| 559 | } |
| 560 | n, _ := h.nodeStore.Get(id) |
| 561 | ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| 562 | defer cancel() |
| 563 | if _, _, err := jobs.ApplyNodeUsers(ctx, client, nodeInbounds, userAccesses, userMap, h.ibStore, h.outboundStore, h.applyOpts, n); err != nil { |
| 564 | log.Printf("applyNodes: apply %s: %v", id, err) |
| 565 | } |
| 566 | }(nodeID) |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | // SyncUserInbounds reconciles a user's inbound assignments. Exported for payment webhook use. |
| 571 | func (h *Handler) SyncUserInbounds(userID string, selectedInboundIDs []string) ([]string, error) { |
no test coverage detected