serializer

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Webhook Events
	CommentCreatedEvent = "comment_created"
	CommentUpdatedEvent = "comment_updated"
	CommentRemovedEvent = "comment_removed"
	PageCreatedEvent    = "page_created"
	PageUpdatedEvent    = "page_updated"
	PageTrashedEvent    = "page_trashed"
	PageRestoredEvent   = "page_restored"
	PageRemovedEvent    = "page_removed"
	SpaceUpdatedEvent   = "space_updated"

	// Subscription Types
	SubscriptionTypeSpace = "space_subscription"
	SubscriptionTypePage  = "page_subscription"
)
View Source
const (
	ConfluenceContentTypePage     = "page"
	ConfluenceContentTypeBlogPost = "blogpost"
	ConfluenceContentTypeComment  = "comment"
)

Variables

SupportedEventsV8AndBelow contains all events supported by Confluence Server v8 and below

SupportedEventsV9AndAbove contains events supported by Confluence Server v9+

Functions

func EventDisplayName added in v1.8.0

func EventDisplayName(event string) string

EventDisplayName returns the display name for an event

func FormattedSubscriptionList

func FormattedSubscriptionList(channelSubscriptions StringSubscription) string

func GetSupportedEvents added in v1.8.0

func GetSupportedEvents(isV9OrAbove bool) []string

GetSupportedEvents returns the list of supported events based on server version

func GetSupportedEventsMap added in v1.8.0

func GetSupportedEventsMap(isV9OrAbove bool) map[string]bool

GetSupportedEventsMap returns the map of supported events based on server version

func UnmarshalCustomSubscription

func UnmarshalCustomSubscription(data []byte, typeJSONField string, customTypes map[string]reflect.Type) (interface{}, error)

UnmarshalCustomSubscription returns subscription from bytes.

func ValidateEventsForServerVersion added in v1.8.0

func ValidateEventsForServerVersion(subscription Subscription, isV9OrAbove bool) error

ValidateEventsForServerVersion validates that subscription events are supported by the server version

Types

type BaseSubscription

type BaseSubscription struct {
	Alias     string   `json:"alias"`
	OldAlias  string   `json:"oldAlias,omitempty"`
	BaseURL   string   `json:"baseURL"`
	Events    []string `json:"events"`
	ChannelID string   `json:"channelID"`
	Type      string   `json:"subscriptionType"`
}

type Comment

type Comment struct {
	CreatorAccountID      string         `json:"creatorAccountId"`
	SpaceKey              string         `json:"spaceKey"`
	ModificationDate      int64          `json:"modificationDate"`
	LastModifierAccountID string         `json:"lastModifierAccountId"`
	Self                  string         `json:"self"`
	ID                    string         `json:"id"`
	CreationDate          int            `json:"creationDate"`
	ContentTypes          string         `json:"contentType"`
	Version               int            `json:"version"`
	Parent                *Page          `json:"parent"`
	InReplyTo             *ParentComment `json:"inReplyTo"`
}

type CommentPayload added in v1.4.0

type CommentPayload struct {
	ID int64 `json:"id"`
}

type ConfluenceCloudEvent

type ConfluenceCloudEvent struct {
	UserAccountID string   `json:"userAccountId"`
	AccountType   string   `json:"accountType"`
	UpdateTrigger string   `json:"updateTrigger"`
	Timestamp     int      `json:"timestamp"`
	Comment       *Comment `json:"comment"`
	Page          *Page    `json:"page"`
}

func ConfluenceCloudEventFromJSON

func ConfluenceCloudEventFromJSON(data io.Reader) (*ConfluenceCloudEvent, error)

func (ConfluenceCloudEvent) GetNotificationPost

func (e ConfluenceCloudEvent) GetNotificationPost(eventType string) *model.Post

func (ConfluenceCloudEvent) GetPageID

func (e ConfluenceCloudEvent) GetPageID() string

func (ConfluenceCloudEvent) GetSpaceKey

func (e ConfluenceCloudEvent) GetSpaceKey() string

func (ConfluenceCloudEvent) GetURL

func (e ConfluenceCloudEvent) GetURL() string

type ConfluenceEvent

type ConfluenceEvent interface {
	GetNotificationPost(string) *model.Post
	GetURL() string
	GetSpaceKey() string
	GetPageID() string
}

type ConfluenceEventV2 added in v1.4.0

type ConfluenceEventV2 interface {
	GetNotificationPost(string, string, string, string) *model.Post
	GetURL() string
	GetSpaceKey() string
	GetPageID() string
}

for handling of Confluence server version greater than 9 notifications

type ConfluenceServerBlogPost

type ConfluenceServerBlogPost struct {
	CreatedAt   int64                `json:"created_at"`
	Title       string               `json:"title"`
	Version     int                  `json:"version"`
	CreatedBy   ConfluenceServerUser `json:"created_by"`
	URL         string               `json:"url"`
	Content     string               `json:"content"`
	Labels      []string             `json:"labels"`
	HTMLContent string               `json:"html_content"`
	ContentType string               `json:"content_type"`
	UpdatedAt   int64                `json:"updated_at"`
	UpdatedBy   ConfluenceServerUser `json:"updated_by"`
	ID          string               `json:"id"`
	Excerpt     string               `json:"excerpt"`
}

type ConfluenceServerComment

type ConfluenceServerComment struct {
	ParentComment    *ConfluenceServerParentComment `json:"parent"`
	DisplayTitle     string                         `json:"display_title"`
	IsInlineComment  bool                           `json:"is_inline_comment"`
	CreatedAt        int64                          `json:"created_at"`
	ThreadChangeDate int64                          `json:"thread_change_date"`
	DescendantsCount int                            `json:"descendants_count"`
	Title            *string                        `json:"title"`
	Version          int                            `json:"version"`
	CreatedBy        ConfluenceServerUser           `json:"created_by"`
	URL              string                         `json:"url"`
	Content          string                         `json:"content"`
	Labels           []string                       `json:"labels"`
	HTMLContent      string                         `json:"html_content"`
	Depth            int                            `json:"depth"`
	ContentType      string                         `json:"content_type"`
	UpdatedAt        int64                          `json:"updated_at"`
	UpdatedBy        ConfluenceServerUser           `json:"updated_by"`
	ID               string                         `json:"id"`
	Excerpt          string                         `json:"excerpt"`
	Status           string                         `json:"status"`
}

type ConfluenceServerEvent

type ConfluenceServerEvent struct {
	VersionComment string                    `json:"version_comment"`
	IsMinorEdit    bool                      `json:"is_minor_edit"`
	Creator        ConfluenceServerUser      `json:"creator"`
	ContentType    string                    `json:"content_type"`
	BaseURL        string                    `json:"base_url"`
	ContentURL     string                    `json:"content_url"`
	ContainerType  string                    `json:"container_type"`
	Comment        *ConfluenceServerComment  `json:"comment"`
	Page           *ConfluenceServerPage     `json:"page"`
	Blog           *ConfluenceServerBlogPost `json:"blog"`
	Event          string                    `json:"event"`
	Excerpt        string                    `json:"excerpt"`
	User           *ConfluenceServerUser     `json:"user"`
	Space          ConfluenceServerSpace     `json:"space"`
	Timestamp      int64                     `json:"timestamp"`
}

func ConfluenceServerEventFromJSON

func ConfluenceServerEventFromJSON(data io.Reader) (*ConfluenceServerEvent, error)

func (*ConfluenceServerEvent) GetBlogDisplayName

func (e *ConfluenceServerEvent) GetBlogDisplayName(withLink bool) string

func (*ConfluenceServerEvent) GetCommentPageOrBlogDisplayName

func (e *ConfluenceServerEvent) GetCommentPageOrBlogDisplayName(withLink bool) string

func (ConfluenceServerEvent) GetNotificationPost

func (e ConfluenceServerEvent) GetNotificationPost(_ string) *model.Post

func (*ConfluenceServerEvent) GetPageDisplayName

func (e *ConfluenceServerEvent) GetPageDisplayName(withLink bool) string

func (ConfluenceServerEvent) GetPageID

func (e ConfluenceServerEvent) GetPageID() string

func (*ConfluenceServerEvent) GetSpaceDisplayName

func (e *ConfluenceServerEvent) GetSpaceDisplayName(withLink bool) string

func (ConfluenceServerEvent) GetSpaceKey

func (e ConfluenceServerEvent) GetSpaceKey() string

func (ConfluenceServerEvent) GetURL

func (e ConfluenceServerEvent) GetURL() string

func (*ConfluenceServerEvent) GetUserDisplayName

func (e *ConfluenceServerEvent) GetUserDisplayName(withLink bool) string

func (*ConfluenceServerEvent) GetUserFirstName

func (e *ConfluenceServerEvent) GetUserFirstName() string

type ConfluenceServerPage

type ConfluenceServerPage struct {
	IsHomePage    bool                           `json:"is_home_page"`
	CreatedAt     int64                          `json:"created_at"`
	Title         string                         `json:"title"`
	Content       string                         `json:"content"`
	HTMLContent   string                         `json:"html_content"`
	IsDeleted     bool                           `json:"is_deleted"`
	ContentType   string                         `json:"content_type"`
	UpdatedAt     int64                          `json:"updated_at"`
	IsDraft       bool                           `json:"is_draft"`
	ID            string                         `json:"id"`
	Ancestors     []ConfluenceServerPageAncestor `json:"ancestors"`
	IsRootLevel   bool                           `json:"is_root_level"`
	ContentID     int                            `json:"content_id"`
	IsIndexable   bool                           `json:"is_indexable"`
	Version       int                            `json:"version"`
	CreatedBy     ConfluenceServerUser           `json:"created_by"`
	URL           string                         `json:"url"`
	Labels        []string                       `json:"labels"`
	TinyURL       string                         `json:"tiny_url"`
	UpdatedBy     ConfluenceServerUser           `json:"updated_by"`
	EditURL       string                         `json:"edit_url"`
	IsUnpublished bool                           `json:"is_unpublished"`
	Position      interface{}                    `json:"position"`
	Excerpt       string                         `json:"excerpt"`
	IsCurrent     bool                           `json:"is_current"`
}

type ConfluenceServerPageAncestor

type ConfluenceServerPageAncestor struct {
	Title string `json:"title"`
	URL   string `json:"url"`
}

type ConfluenceServerParentComment

type ConfluenceServerParentComment struct {
	CreatedAt   int64                `json:"created_at"`
	Title       *string              `json:"title"`
	Version     int                  `json:"version"`
	CreatedBy   ConfluenceServerUser `json:"created_by"`
	URL         string               `json:"url"`
	Content     string               `json:"content"`
	Labels      []string             `json:"labels"`
	HTMLContent string               `json:"html_content"`
	ContentType string               `json:"content_type"`
	UpdatedAt   int64                `json:"updated_at"`
	UpdatedBy   ConfluenceServerUser `json:"updated_by"`
	ID          string               `json:"id"`
	Excerpt     string               `json:"excerpt"`
}

type ConfluenceServerSpace

type ConfluenceServerSpace struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Key         string `json:"key"`
	URL         string `json:"url"`
	Status      string `json:"status"`
}

type ConfluenceServerUser

type ConfluenceServerUser struct {
	FullName string `json:"full_name"`
	Email    string `json:"email"`
	URL      string `json:"url"`
	Username string `json:"username"`
}

type ConfluenceServerWebhookPayload added in v1.4.0

type ConfluenceServerWebhookPayload struct {
	Timestamp int64          `json:"timestamp"`
	Event     string         `json:"event"`
	UserKey   string         `json:"userKey"`
	Comment   CommentPayload `json:"comment"`
	Page      PagePayload    `json:"page"`
	Space     SpacePayload   `json:"space"`
}

type Page

type Page struct {
	CreatorAccountID      string `json:"creatorAccountId"`
	SpaceKey              string `json:"spaceKey"`
	ModificationDate      int64  `json:"modificationDate"`
	LastModifierAccountID string `json:"lastModifierAccountId"`
	Self                  string `json:"self"`
	ID                    string `json:"id"`
	Title                 string `json:"title"`
	CreationDate          int    `json:"creationDate"`
	ContentTypes          string `json:"contentType"`
	Version               int    `json:"version"`
}

type PagePayload added in v1.4.0

type PagePayload struct {
	ID int64 `json:"id"`
}

type PageSubscription

type PageSubscription struct {
	PageID string `json:"pageID"`
	BaseSubscription
}

func PageSubscriptionFromJSON

func PageSubscriptionFromJSON(data io.Reader, subscriptionType string) (PageSubscription, error)

func (PageSubscription) Add

func (PageSubscription) Edit

func (ps PageSubscription) Edit(s *Subscriptions) error

func (PageSubscription) GetAlias added in v1.3.0

func (ps PageSubscription) GetAlias() string

func (PageSubscription) GetFormattedSubscription

func (ps PageSubscription) GetFormattedSubscription() string

func (PageSubscription) IsValid

func (ps PageSubscription) IsValid() error

func (PageSubscription) Name

func (ps PageSubscription) Name() string

func (PageSubscription) Remove

func (ps PageSubscription) Remove(s *Subscriptions) error

func (PageSubscription) ValidateSubscription

func (ps PageSubscription) ValidateSubscription(subs *Subscriptions) error

type ParentComment

type ParentComment struct {
	ID string `json:"id"`
}

type SpacePayload added in v1.4.0

type SpacePayload struct {
	ID       int64  `json:"id"`
	SpaceKey string `json:"spaceKey"`
}

type SpaceSubscription

type SpaceSubscription struct {
	SpaceKey string `json:"spaceKey"`
	BaseSubscription
}

func SpaceSubscriptionFromJSON

func SpaceSubscriptionFromJSON(data io.Reader, subscriptionType string) (SpaceSubscription, error)

func (SpaceSubscription) Add

func (SpaceSubscription) Edit

func (SpaceSubscription) GetAlias added in v1.3.0

func (ss SpaceSubscription) GetAlias() string

func (SpaceSubscription) GetFormattedSubscription

func (ss SpaceSubscription) GetFormattedSubscription() string

func (SpaceSubscription) IsValid

func (ss SpaceSubscription) IsValid() error

func (SpaceSubscription) Name

func (ss SpaceSubscription) Name() string

func (SpaceSubscription) Remove

func (ss SpaceSubscription) Remove(s *Subscriptions) error

func (SpaceSubscription) ValidateSubscription

func (ss SpaceSubscription) ValidateSubscription(subs *Subscriptions) error

type StringArrayMap

type StringArrayMap map[string][]string

type StringSubscription

type StringSubscription map[string]Subscription

func (StringSubscription) GetInsensitiveCase added in v1.2.0

func (s StringSubscription) GetInsensitiveCase(key string) (Subscription, bool)

func (*StringSubscription) UnmarshalJSON

func (s *StringSubscription) UnmarshalJSON(data []byte) error

Used indirectly by StringSubscription.UnmarshalJSON during subscription deserialization

type Subscription

type Subscription interface {
	Add(*Subscriptions) error
	Remove(*Subscriptions) error
	Edit(*Subscriptions) error
	Name() string
	GetAlias() string
	GetFormattedSubscription() string
	IsValid() error
	ValidateSubscription(*Subscriptions) error
}

type Subscriptions

type Subscriptions struct {
	ByChannelID   map[string]StringSubscription
	ByURLPageID   map[string]StringArrayMap
	ByURLSpaceKey map[string]StringArrayMap
}

func NewSubscriptions

func NewSubscriptions() *Subscriptions

func SubscriptionsFromJSON

func SubscriptionsFromJSON(bytes []byte) (*Subscriptions, error)

func (*Subscriptions) EnsureDefaults added in v1.4.0

func (s *Subscriptions) EnsureDefaults()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL