discourse

package
v0.0.0-...-2f3eae6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ErrEmptyParam = merr.Code("empty_param")

Variables

This section is empty.

Functions

func PluginDCDataExplorerQueryResultUnmarshal

func PluginDCDataExplorerQueryResultUnmarshal[T any](ctx context.Context, res *PluginDCDataExplorerQueryResult) ([]T, error)

Types

type Archetype

type Archetype string
const (
	ArchetypeRegular        Archetype = "regular"
	ArchetypePrivateMessage Archetype = "private_message"
	ArchetypeBanner         Archetype = "banner"
)

type Category

type Category struct {
	ID              int        `json:"id"`
	Name            string     `json:"name"`
	Slug            string     `json:"slug"`
	ReadRestricted  bool       `json:"read_restricted"`
	SubcategoryIDs  []int      `json:"subcategory_ids"`
	SubcategoryList []Category `json:"subcategory_list"`
}

type CategoryList

type CategoryList struct {
	Categories []Category `json:"categories"`
}

type CategoryListResult

type CategoryListResult struct {
	CategoryList CategoryList `json:"category_list"`
}

type Client

type Client struct {
	BaseURL *url.URL
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL *url.URL, apiKey string) *Client

func (*Client) AsSystem

func (c *Client) AsSystem() *IdentifiedClient

func (*Client) AsUsername

func (c *Client) AsUsername(username string) *IdentifiedClient

type ConnectClient

type ConnectClient struct {
	// contains filtered or unexported fields
}

func NewConnectClient

func NewConnectClient(client *Client, connectSecret string) *ConnectClient

func (*ConnectClient) ParseAndVerify

func (c *ConnectClient) ParseAndVerify(ctx context.Context, sso, sig string) (url.Values, error)

func (*ConnectClient) StringifyAndSign

func (c *ConnectClient) StringifyAndSign(params url.Values) (sso, sig string)

func (*ConnectClient) SyncSSO

func (c *ConnectClient) SyncSSO(ctx context.Context, params url.Values) error

type GetTopicOptions

type GetTopicOptions struct {
	Print bool
}

type IdentifiedClient

type IdentifiedClient struct {
	// contains filtered or unexported fields
}

func (*IdentifiedClient) AdminAnonymizeUser

func (c *IdentifiedClient) AdminAnonymizeUser(ctx context.Context, userID int) error

func (*IdentifiedClient) AdminGetUserByID

func (c *IdentifiedClient) AdminGetUserByID(ctx context.Context, userID int) (res *User, err error)

func (*IdentifiedClient) CreatePost

func (c *IdentifiedClient) CreatePost(ctx context.Context, req *PostNew) (res *Post, err error)

func (*IdentifiedClient) GetPostByID

func (c *IdentifiedClient) GetPostByID(ctx context.Context, postID int) (res *Post, err error)

func (*IdentifiedClient) GetTopic

func (c *IdentifiedClient) GetTopic(ctx context.Context, topicID int, options *GetTopicOptions) (res *TopicResult, err error)

func (*IdentifiedClient) GetUserByExternalID

func (c *IdentifiedClient) GetUserByExternalID(ctx context.Context, externalID string) (res *UserResult, err error)

func (*IdentifiedClient) GetUserByUsername

func (c *IdentifiedClient) GetUserByUsername(ctx context.Context, username string) (res *UserResult, err error)

func (*IdentifiedClient) ListCategories

func (c *IdentifiedClient) ListCategories(ctx context.Context, options *ListCategoriesOptions) (res *CategoryListResult, err error)

func (*IdentifiedClient) ListTopicPostIDs

func (c *IdentifiedClient) ListTopicPostIDs(ctx context.Context, topicID int, options *ListTopicPostIDsOptions) (res *PostIDsResult, err error)

func (*IdentifiedClient) ListTopicPostsByIDs

func (c *IdentifiedClient) ListTopicPostsByIDs(ctx context.Context, topicID int, postIDs []int) (res *PostStreamResult, err error)

func (*IdentifiedClient) PluginDCDataExplorerRunQuery

func (c *IdentifiedClient) PluginDCDataExplorerRunQuery(ctx context.Context, queryID int, options *PluginDCDataExplorerRunQueryOptions) (res *PluginDCDataExplorerQueryResult, err error)

func (*IdentifiedClient) PluginDCReactionsToggleReaction

func (c *IdentifiedClient) PluginDCReactionsToggleReaction(ctx context.Context, postID int, reactionID string) (res *Post, err error)

type ListCategoriesOptions

type ListCategoriesOptions struct {
	IncludeSubcategories bool
}

type ListTopicPostIDsOptions

type ListTopicPostIDsOptions struct {
	PostNumber int
}

type PluginDCDataExplorerQueryResult

type PluginDCDataExplorerQueryResult struct {
	// Errors indicates what went wrong with the query.
	//
	// At the time of writing, it is always empty when the request is successful.
	//
	// https://github.com/discourse/discourse-data-explorer/blob/2f1044820c479424d29d94df389360b1d9dee871/app/controllers/discourse_data_explorer/query_controller.rb#L193
	Errors []string `json:"errors"`

	Duration     float64                     `json:"duration"`
	ResultCount  int                         `json:"result_count"`
	Params       map[string]any              `json:"params"`
	Columns      []string                    `json:"columns"`
	DefaultLimit int                         `json:"default_limit"`
	Explain      *string                     `json:"explain"`
	Relations    map[string][]map[string]any `json:"relations"`
	ColRender    map[string]string           `json:"colrender"`
	Rows         [][]any                     `json:"rows"`
}

type PluginDCDataExplorerRunQueryOptions

type PluginDCDataExplorerRunQueryOptions struct {
	Params   map[string]any
	Explain  bool
	Download bool
	LimitAll bool
}

type PluginDCReactionsPostReaction

type PluginDCReactionsPostReaction struct {
	ID    string                        `json:"id"`
	Type  PluginDCReactionsReactionType `json:"type"`
	Count int                           `json:"count"`
}

type PluginDCReactionsPostReactionCurrentUser

type PluginDCReactionsPostReactionCurrentUser struct {
	ID   string                        `json:"id"`
	Type PluginDCReactionsReactionType `json:"type"`
}

type PluginDCReactionsReactionType

type PluginDCReactionsReactionType string
const (
	PluginDCReactionsReactionTypeEmoji PluginDCReactionsReactionType = "emoji"
)

type Post

type Post struct {
	ID                int        `json:"id"`
	Username          string     `json:"username"`
	AvatarTemplate    string     `json:"avatar_template"`
	CreatedAt         time.Time  `json:"created_at"`
	Raw               string     `json:"raw"`
	Cooked            string     `json:"cooked"`
	PostNumber        int        `json:"post_number"`
	PostType          PostType   `json:"post_type"`
	UpdatedAt         time.Time  `json:"updated_at"`
	ReplyToPostNumber *int       `json:"reply_to_post_number"`
	TopicID           int        `json:"topic_id"`
	Version           int        `json:"version"`
	UserID            int        `json:"user_id"`
	Hidden            bool       `json:"hidden"`
	DeletedAt         *time.Time `json:"deleted_at"`
	Wiki              bool       `json:"wiki"`

	// Discourse Reactions plugin
	Reactions           []PluginDCReactionsPostReaction           `json:"reactions"`
	CurrentUserReaction *PluginDCReactionsPostReactionCurrentUser `json:"current_user_reaction"`
}

type PostIDsResult

type PostIDsResult struct {
	PostIDs []int `json:"post_ids"`
}

type PostNew

type PostNew struct {
	Title             *string `json:"title"`
	Raw               string  `json:"raw"`
	TopicID           *int    `json:"topic_id"`
	Category          *int    `json:"category"`
	ReplyToPostNumber *int    `json:"reply_to_post_number"`
}

type PostStream

type PostStream struct {
	Posts  []Post `json:"posts"`
	Stream []int  `json:"stream"`
}

type PostStreamResult

type PostStreamResult struct {
	PostStream PostStream `json:"post_stream"`
}

type PostType

type PostType int
const (
	PostTypeRegular         PostType = 1
	PostTypeModeratorAction PostType = 2
	PostTypeSmallAction     PostType = 3
	PostTypeWhisper         PostType = 4
)

type Topic

type Topic struct {
	ID                int          `json:"id"`
	Title             string       `json:"title"`
	FancyTitle        string       `json:"fancy_title"`
	Slug              string       `json:"slug"`
	PostsCount        int          `json:"posts_count"`
	ReplyCount        int          `json:"reply_count"`
	HighestPostNumber int          `json:"highest_post_number"`
	ImageURL          *string      `json:"image_url"`
	CreatedAt         time.Time    `json:"created_at"`
	LastPostedAt      *time.Time   `json:"last_posted_at"`
	Archetype         Archetype    `json:"archetype"`
	Pinned            bool         `json:"pinned"`
	Unpinned          *time.Time   `json:"unpinned"`
	Visible           bool         `json:"visible"`
	Closed            bool         `json:"closed"`
	Archived          bool         `json:"archived"`
	Tags              []string     `json:"tags"`
	CategoryID        int          `json:"category_id"`
	PinnedGlobally    bool         `json:"pinned_globally"`
	FeaturedLink      *string      `json:"featured_link"`
	Details           TopicDetails `json:"details"`
}

type TopicCreatedBy

type TopicCreatedBy struct {
	ID             int    `json:"id"`
	Username       string `json:"username"`
	AvatarTemplate string `json:"avatar_template"`
}

type TopicDetails

type TopicDetails struct {
	CreatedBy TopicCreatedBy `json:"created_by"`
}

type TopicResult

type TopicResult struct {
	PostStreamResult
	Topic

	UserID int `json:"user_id"`
}

type User

type User struct {
	ID                 int                     `json:"id"`
	Username           string                  `json:"username"`
	AvatarTemplate     *string                 `json:"avatar_template"`
	SingleSignOnRecord *UserSingleSignOnRecord `json:"single_sign_on_record"`
}

type UserResult

type UserResult struct {
	User User `json:"user"`
}

type UserSingleSignOnRecord

type UserSingleSignOnRecord struct {
	ExternalID string `json:"external_id"`
}

Jump to

Keyboard shortcuts

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