( ctx context.Context, scope toolspkg.Scope, req toolspkg.CallRequest, mode string, )
| 1785 | } |
| 1786 | |
| 1787 | func (n *daemonNativeTools) networkSetSubscription( |
| 1788 | ctx context.Context, |
| 1789 | scope toolspkg.Scope, |
| 1790 | req toolspkg.CallRequest, |
| 1791 | mode string, |
| 1792 | ) (toolspkg.ToolResult, error) { |
| 1793 | var input networkSubscriptionInput |
| 1794 | if err := decodeNativeInput(req, &input); err != nil { |
| 1795 | return toolspkg.ToolResult{}, err |
| 1796 | } |
| 1797 | channel, err := nativeNetworkChannel(req.ToolID, input.Channel) |
| 1798 | if err != nil { |
| 1799 | return toolspkg.ToolResult{}, err |
| 1800 | } |
| 1801 | workspaceID, err := n.nativeNetworkWorkspaceID(ctx, req.ToolID, input.WorkspaceID, scope) |
| 1802 | if err != nil { |
| 1803 | return toolspkg.ToolResult{}, err |
| 1804 | } |
| 1805 | now := time.Now().UTC() |
| 1806 | entry := store.NetworkSubscriptionEntry{ |
| 1807 | WorkspaceID: workspaceID, |
| 1808 | Channel: channel, |
| 1809 | ThreadID: strings.TrimSpace(input.ThreadID), |
| 1810 | PeerID: strings.TrimSpace(input.PeerID), |
| 1811 | Mode: mode, |
| 1812 | KeywordFilters: cloneTrimmedStrings(input.KeywordFilters), |
| 1813 | CreatedAt: now, |
| 1814 | UpdatedAt: now, |
| 1815 | } |
| 1816 | if err := entry.Validate(); err != nil { |
| 1817 | return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err) |
| 1818 | } |
| 1819 | if err := n.ensureNativeNetworkSubscriptionChannel(ctx, scope, entry); err != nil { |
| 1820 | return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err) |
| 1821 | } |
| 1822 | if err := n.deps.NetworkStore.PutNetworkSubscription(ctx, entry); err != nil { |
| 1823 | return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err) |
| 1824 | } |
| 1825 | payload := core.NetworkSubscriptionPayloadFromStore(entry) |
| 1826 | return structuredNetworkResult(map[string]any{"subscription": payload}, payload.Mode) |
| 1827 | } |
| 1828 | |
| 1829 | func (n *daemonNativeTools) ensureNativeNetworkSubscriptionChannel( |
| 1830 | ctx context.Context, |
no test coverage detected