Skip to main content

Subscribe to an extra view

Motivation

As a client, I want to add a subscription to an existing channel

Functional Design

  • The client initiates PUT /api/v2/apps/{owner}/{app}/notifications/{channelId}/workspaces/{wsid}/subscriptions/{entity}
  • The subscription is added to the channel in addition to existing subscriptions, the client starts receiving notifications about changes in the specified entity.
  • If the subscription already exists, it does nothing

Request headers

KeyValue
Content-Typeapplication/json
AuthorizationBearer {PrincipalToken}

Parameters

ParameterTypeDescription
Path
ownerstringname of a user who owns the application
appstringname of an application
wsidint64the ID of workspace
channelIdstringthe ID of the channel, returned by create channel
entitystringSubscription entity, see terms
Headers
PrincipalTokenstringToken returned by login

Authorization

  • If entity refers to a view, the client must have read permission for that view in the specified workspace.

Result

CodeDescriptionBody
200OKChannel subscription added
400Bad Requesterror object
401Unauthorizederror object
403Forbidden, client has no permissions to read from viewerror object
404Not Founderror object
429Too may requests, rate limitingerror object
500+Server errors / service unavailableerror object

Technical design

Components

  • ~cmp.routerAddSubscriptionHandler~covrd1✅ function to handle the request in router
    • ~err.routerAddSubscriptionInvalidToken~covrd2✅ if the token is invalid or expired
    • ~err.routerAddSubscriptionNoPermissions~uncvrd3❓ if the client has no permissions to read from the specified view

Integration tests

  • ~it.AddSubscription~covrd4

Footnotes

  1. [~server.n10n/cmp.routerAddSubscriptionHandler~impl] pkg/router/impl_apiv2.go:170:impl

  2. [~server.n10n/err.routerAddSubscriptionInvalidToken~impl] pkg/router/impl_apiv2.go:341:impl

  3. [~server.n10n/err.routerAddSubscriptionNoPermissions~impl]

  4. [~server.n10n/it.AddSubscription~impl] pkg/sys/it/impl_n10n_test.go:414:impl