v1

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LocalStorage means the storage service is local file system.
	LocalStorage int32 = -1
	// DatabaseStorage means the storage service is database.
	DatabaseStorage int32 = 0
	// Default storage service is database.
	DefaultStorage int32 = DatabaseStorage
)
View Source
const (
	MebiByte = 1024 * 1024
)

Variables

View Source
var SwaggerInfo = &swag.Spec{
	Version:          "1.0",
	Host:             "",
	BasePath:         "/",
	Schemes:          []string{},
	Title:            "memos API",
	Description:      "A privacy-first, lightweight note-taking service.",
	InfoInstanceName: "swagger",
	SwaggerTemplate:  docTemplate,
	LeftDelim:        "{{",
	RightDelim:       "}}",
}

SwaggerInfo holds exported Swagger Info so clients can modify it

Functions

func GetImage added in v0.14.4

func GetImage(c echo.Context) error

GetImage godoc

@Summary	Get GetImage from URL
@Tags		image-url
@Produce	GetImage/*
@Param		url	query		string	true	"Image url"
@Success	200	{object}	nil		"Image"
@Failure	400	{object}	nil		"Missing GetImage url | Wrong url | Failed to get GetImage url: %s"
@Failure	500	{object}	nil		"Failed to write GetImage blob"
@Router		/o/get/GetImage [GET]

func JWTMiddleware

func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) echo.HandlerFunc

JWTMiddleware validates the access token.

func SaveResourceBlob added in v0.14.0

func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resource, r io.Reader) error

SaveResourceBlob save the blob of resource based on the storage config

Depend on the storage config, some fields of *store.ResourceCreate will be changed: 1. *DatabaseStorage*: `create.Blob`. 2. *LocalStorage*: `create.InternalPath`. 3. Others( external service): `create.ExternalLink`.

Types

type APIV1Service

type APIV1Service struct {
	Secret  string
	Profile *profile.Profile
	Store   *store.Store
	// contains filtered or unexported fields
}

func NewAPIV1Service

func NewAPIV1Service(secret string, profile *profile.Profile, store *store.Store, telegramBot *telegram.Bot) *APIV1Service

@title memos API @version 1.0 @description A privacy-first, lightweight note-taking service.

@contact.name API Support @contact.url https://github.com/orgs/usememos/discussions

@license.name MIT License @license.url https://github.com/usememos/memos/blob/main/LICENSE

@BasePath /

@externalDocs.url https://usememos.com/ @externalDocs.description Find out more about Memos.

func (*APIV1Service) CreateIdentityProvider added in v0.14.4

func (s *APIV1Service) CreateIdentityProvider(c echo.Context) error

CreateIdentityProvider godoc

@Summary	Create Identity Provider
@Tags		idp
@Accept		json
@Produce	json
@Param		body	body		CreateIdentityProviderRequest	true	"Identity provider information"
@Success	200		{object}	store.IdentityProvider			"Identity provider information"
@Failure	401		{object}	nil								"Missing user in session | Unauthorized"
@Failure	400		{object}	nil								"Malformatted post identity provider request"
@Failure	500		{object}	nil								"Failed to find user | Failed to create identity provider"
@Router		/api/v1/idp [POST]

func (*APIV1Service) CreateMemo added in v0.14.4

func (s *APIV1Service) CreateMemo(c echo.Context) error

CreateMemo godoc

@Summary		Create a memo
@Description	Visibility can be PUBLIC, PROTECTED or PRIVATE
@Description	*You should omit fields to use their default values
@Tags			memo
@Accept			json
@Produce		json
@Param			body	body		CreateMemoRequest	true	"Request object."
@Success		200		{object}	store.Memo			"Stored memo"
@Failure		400		{object}	nil					"Malformatted post memo request | Content size overflow, up to 1MB"
@Failure		401		{object}	nil					"Missing user in session"
@Failure		404		{object}	nil					"User not found | Memo not found: %d"
@Failure		500		{object}	nil					"Failed to find user setting | Failed to unmarshal user setting value | Failed to find system setting | Failed to unmarshal system setting | Failed to find user | Failed to create memo | Failed to create activity | Failed to upsert memo resource | Failed to upsert memo relation | Failed to compose memo | Failed to compose memo response"
@Router			/api/v1/memo [POST]

NOTES: - It's currently possible to create phantom resources and relations. Phantom relations will trigger backend 404's when fetching memo.

func (*APIV1Service) CreateMemoOrganizer added in v0.14.4

func (s *APIV1Service) CreateMemoOrganizer(c echo.Context) error

CreateMemoOrganizer godoc

@Summary	Organize memo (pin/unpin)
@Tags		memo-organizer
@Accept		json
@Produce	json
@Param		memoId	path		int							true	"ID of memo to organize"
@Param		body	body		UpsertMemoOrganizerRequest	true	"Memo organizer object"
@Success	200		{object}	store.Memo					"Memo information"
@Failure	400		{object}	nil							"ID is not a number: %s | Malformatted post memo organizer request"
@Failure	401		{object}	nil							"Missing user in session | Unauthorized"
@Failure	404		{object}	nil							"Memo not found: %v"
@Failure	500		{object}	nil							"Failed to find memo | Failed to upsert memo organizer | Failed to find memo by ID: %v | Failed to compose memo response"
@Router		/api/v1/memo/{memoId}/organizer [POST]

func (*APIV1Service) CreateMemoRelation added in v0.14.4

func (s *APIV1Service) CreateMemoRelation(c echo.Context) error

CreateMemoRelation godoc

@Summary		Create Memo Relation
@Description	Create a relation between two memos
@Tags			memo-relation
@Accept			json
@Produce		json
@Param			memoId	path		int							true	"ID of memo to relate"
@Param			body	body		UpsertMemoRelationRequest	true	"Memo relation object"
@Success		200		{object}	store.MemoRelation			"Memo relation information"
@Failure		400		{object}	nil							"ID is not a number: %s | Malformatted post memo relation request"
@Failure		500		{object}	nil							"Failed to upsert memo relation"
@Router			/api/v1/memo/{memoId}/relation [POST]

NOTES: - Currently not secured - It's possible to create relations to memos that doesn't exist, which will trigger 404 errors when the frontend tries to load them. - It's possible to create multiple relations, though the interface only shows first.

func (*APIV1Service) CreateResource added in v0.14.4

func (s *APIV1Service) CreateResource(c echo.Context) error

CreateResource godoc

@Summary	Create resource
@Tags		resource
@Accept		json
@Produce	json
@Param		body	body		CreateResourceRequest	true	"Request object."
@Success	200		{object}	store.Resource			"Created resource"
@Failure	400		{object}	nil						"Malformatted post resource request | Invalid external link | Invalid external link scheme | Failed to request %s | Failed to read %s | Failed to read mime from %s"
@Failure	401		{object}	nil						"Missing user in session"
@Failure	500		{object}	nil						"Failed to save resource | Failed to create resource | Failed to create activity"
@Router		/api/v1/resource [POST]

func (*APIV1Service) CreateStorage added in v0.14.4

func (s *APIV1Service) CreateStorage(c echo.Context) error

CreateStorage godoc

@Summary	Create storage
@Tags		storage
@Accept		json
@Produce	json
@Param		body	body		CreateStorageRequest	true	"Request object."
@Success	200		{object}	store.Storage			"Created storage"
@Failure	400		{object}	nil						"Malformatted post storage request"
@Failure	401		{object}	nil						"Missing user in session"
@Failure	500		{object}	nil						"Failed to find user | Failed to create storage | Failed to convert storage"
@Router		/api/v1/storage [POST]

func (*APIV1Service) CreateSystemSetting added in v0.14.4

func (s *APIV1Service) CreateSystemSetting(c echo.Context) error

CreateSystemSetting godoc

@Summary	Create system setting
@Tags		system-setting
@Accept		json
@Produce	json
@Param		body	body		UpsertSystemSettingRequest	true	"Request object."
@Success	200		{object}	store.SystemSetting			"Created system setting"
@Failure	400		{object}	nil							"Malformatted post system setting request | invalid system setting"
@Failure	401		{object}	nil							"Missing user in session | Unauthorized"
@Failure	403		{object}	nil							"Cannot disable passwords if no SSO identity provider is configured."
@Failure	500		{object}	nil							"Failed to find user | Failed to upsert system setting"
@Router		/api/v1/system/setting [POST]

func (*APIV1Service) CreateTag added in v0.14.4

func (s *APIV1Service) CreateTag(c echo.Context) error

CreateTag godoc

@Summary	Create a tag
@Tags		tag
@Accept		json
@Produce	json
@Param		body	body		UpsertTagRequest	true	"Request object."
@Success	200		{object}	string				"Created tag name"
@Failure	400		{object}	nil					"Malformatted post tag request | Tag name shouldn't be empty"
@Failure	401		{object}	nil					"Missing user in session"
@Failure	500		{object}	nil					"Failed to upsert tag | Failed to create activity"
@Router		/api/v1/tag [POST]

func (*APIV1Service) CreateUser added in v0.14.4

func (s *APIV1Service) CreateUser(c echo.Context) error

CreateUser godoc

@Summary	Create a user
@Tags		user
@Accept		json
@Produce	json
@Param		body	body		CreateUserRequest	true	"Request object"
@Success	200		{object}	store.User			"Created user"
@Failure	400		{object}	nil					"Malformatted post user request | Invalid user create format"
@Failure	401		{object}	nil					"Missing auth session | Unauthorized to create user"
@Failure	403		{object}	nil					"Could not create host user"
@Failure	500		{object}	nil					"Failed to find user by id | Failed to generate password hash | Failed to create user | Failed to create activity"
@Router		/api/v1/user [POST]

func (*APIV1Service) DeleteIdentityProvider added in v0.14.4

func (s *APIV1Service) DeleteIdentityProvider(c echo.Context) error

DeleteIdentityProvider godoc

@Summary	Delete an identity provider by ID
@Tags		idp
@Accept		json
@Produce	json
@Param		idpId	path		int		true	"Identity Provider ID"
@Success	200		{boolean}	true	"Identity Provider deleted"
@Failure	400		{object}	nil		"ID is not a number: %s | Malformatted patch identity provider request"
@Failure	401		{object}	nil		"Missing user in session | Unauthorized"
@Failure	500		{object}	nil		"Failed to find user | Failed to patch identity provider"
@Router		/api/v1/idp/{idpId} [DELETE]

func (*APIV1Service) DeleteMemo added in v0.14.4

func (s *APIV1Service) DeleteMemo(c echo.Context) error

DeleteMemo godoc

@Summary	Delete memo by ID
@Tags		memo
@Produce	json
@Param		memoId	path		int		true	"Memo ID to delete"
@Success	200		{boolean}	true	"Memo deleted"
@Failure	400		{object}	nil		"ID is not a number: %s"
@Failure	401		{object}	nil		"Missing user in session | Unauthorized"
@Failure	404		{object}	nil		"Memo not found: %d"
@Failure	500		{object}	nil		"Failed to find memo | Failed to delete memo ID: %v"
@Router		/api/v1/memo/{memoId} [DELETE]

func (*APIV1Service) DeleteMemoRelation added in v0.14.4

func (s *APIV1Service) DeleteMemoRelation(c echo.Context) error

DeleteMemoRelation godoc

@Summary		Delete a Memo Relation
@Description	Removes a relation between two memos
@Tags			memo-relation
@Accept			json
@Produce		json
@Param			memoId			path		int					true	"ID of memo to find relations"
@Param			relatedMemoId	path		int					true	"ID of memo to remove relation to"
@Param			relationType	path		MemoRelationType	true	"Type of relation to remove"
@Success		200				{boolean}	true				"Memo relation deleted"
@Failure		400				{object}	nil					"Memo ID is not a number: %s | Related memo ID is not a number: %s"
@Failure		500				{object}	nil					"Failed to delete memo relation"
@Router			/api/v1/memo/{memoId}/relation/{relatedMemoId}/type/{relationType} [DELETE]

NOTES: - Currently not secured. - Will always return true, even if the relation doesn't exist.

func (*APIV1Service) DeleteResource added in v0.14.4

func (s *APIV1Service) DeleteResource(c echo.Context) error

DeleteResource godoc

@Summary	Delete a resource
@Tags		resource
@Produce	json
@Param		resourceId	path		int		true	"Resource ID"
@Success	200			{boolean}	true	"Resource deleted"
@Failure	400			{object}	nil		"ID is not a number: %s"
@Failure	401			{object}	nil		"Missing user in session"
@Failure	404			{object}	nil		"Resource not found: %d"
@Failure	500			{object}	nil		"Failed to find resource | Failed to delete resource"
@Router		/api/v1/resource/{resourceId} [DELETE]

func (*APIV1Service) DeleteStorage added in v0.14.4

func (s *APIV1Service) DeleteStorage(c echo.Context) error

DeleteStorage godoc

@Summary	Delete a storage
@Tags		storage
@Produce	json
@Param		storageId	path		int		true	"Storage ID"
@Success	200			{boolean}	true	"Storage deleted"
@Failure	400			{object}	nil		"ID is not a number: %s | Storage service %d is using"
@Failure	401			{object}	nil		"Missing user in session | Unauthorized"
@Failure	500			{object}	nil		"Failed to find user | Failed to find storage | Failed to unmarshal storage service id | Failed to delete storage"
@Router		/api/v1/storage/{storageId} [DELETE]

NOTES: - error message "Storage service %d is using" probably should be "Storage service %d is in use".

func (*APIV1Service) DeleteTag added in v0.14.4

func (s *APIV1Service) DeleteTag(c echo.Context) error

DeleteTag godoc

@Summary	Delete a tag
@Tags		tag
@Accept		json
@Produce	json
@Param		body	body		DeleteTagRequest	true	"Request object."
@Success	200		{boolean}	true				"Tag deleted"
@Failure	400		{object}	nil					"Malformatted post tag request | Tag name shouldn't be empty"
@Failure	401		{object}	nil					"Missing user in session"
@Failure	500		{object}	nil					"Failed to delete tag name: %v"
@Router		/api/v1/tag/delete [POST]

func (*APIV1Service) DeleteUser added in v0.14.4

func (s *APIV1Service) DeleteUser(c echo.Context) error

DeleteUser godoc

@Summary	Delete a user
@Tags		user
@Produce	json
@Param		id	path		string	true	"User ID"
@Success	200	{boolean}	true	"User deleted"
@Failure	400	{object}	nil		"ID is not a number: %s | Current session user not found with ID: %d"
@Failure	401	{object}	nil		"Missing user in session"
@Failure	403	{object}	nil		"Unauthorized to delete user"
@Failure	500	{object}	nil		"Failed to find user | Failed to delete user"
@Router		/api/v1/user/{id} [DELETE]

func (*APIV1Service) DispatchMemoCreatedWebhook added in v0.18.0

func (s *APIV1Service) DispatchMemoCreatedWebhook(ctx context.Context, memo *Memo) error

DispatchMemoCreatedWebhook dispatches webhook when memo is created.

func (*APIV1Service) DispatchMemoUpdatedWebhook added in v0.18.0

func (s *APIV1Service) DispatchMemoUpdatedWebhook(ctx context.Context, memo *Memo) error

DispatchMemoUpdatedWebhook dispatches webhook when memo is updated.

func (*APIV1Service) ExecVacuum added in v0.14.4

func (s *APIV1Service) ExecVacuum(c echo.Context) error

ExecVacuum godoc

@Summary	Vacuum the database
@Tags		system
@Produce	json
@Success	200	{boolean}	true	"Database vacuumed"
@Failure	401	{object}	nil		"Missing user in session | Unauthorized"
@Failure	500	{object}	nil		"Failed to find user | Failed to ExecVacuum database"
@Router		/api/v1/system/vacuum [POST]

func (*APIV1Service) GetAllMemos added in v0.14.4

func (s *APIV1Service) GetAllMemos(c echo.Context) error

GetAllMemos godoc

@Summary		Get a list of public memos matching optional filters
@Description	This should also list protected memos if the user is logged in
@Description	Authentication is optional
@Tags			memo
@Produce		json
@Param			limit	query		int				false	"Limit"
@Param			offset	query		int				false	"Offset"
@Success		200		{object}	[]store.Memo	"Memo list"
@Failure		500		{object}	nil				"Failed to get memo display with updated ts setting value | Failed to fetch all memo list | Failed to compose memo response"
@Router			/api/v1/memo/all [GET]

NOTES:
- creatorUsername is listed at ./web/src/helpers/api.ts:82, but it's not present here

func (*APIV1Service) GetCurrentUser added in v0.14.4

func (s *APIV1Service) GetCurrentUser(c echo.Context) error

GetCurrentUser godoc

@Summary	Get current user
@Tags		user
@Produce	json
@Success	200	{object}	store.User	"Current user"
@Failure	401	{object}	nil			"Missing auth session"
@Failure	500	{object}	nil			"Failed to find user | Failed to find userSettingList"
@Router		/api/v1/user/me [GET]

func (*APIV1Service) GetExploreRSS added in v0.14.4

func (s *APIV1Service) GetExploreRSS(c echo.Context) error

GetExploreRSS godoc

@Summary	Get RSS
@Tags		rss
@Produce	xml
@Success	200	{object}	nil	"RSS"
@Failure	500	{object}	nil	"Failed to get system customized profile | Failed to find memo list | Failed to generate rss"
@Router		/explore/rss.xml [GET]

func (*APIV1Service) GetIdentityProvider added in v0.14.4

func (s *APIV1Service) GetIdentityProvider(c echo.Context) error

GetIdentityProvider godoc

@Summary	Get an identity provider by ID
@Tags		idp
@Accept		json
@Produce	json
@Param		idpId	path		int						true	"Identity provider ID"
@Success	200		{object}	store.IdentityProvider	"Requested identity provider"
@Failure	400		{object}	nil						"ID is not a number: %s"
@Failure	401		{object}	nil						"Missing user in session | Unauthorized"
@Failure	404		{object}	nil						"Identity provider not found"
@Failure	500		{object}	nil						"Failed to find identity provider list | Failed to find user"
@Router		/api/v1/idp/{idpId} [GET]

func (*APIV1Service) GetIdentityProviderList added in v0.14.4

func (s *APIV1Service) GetIdentityProviderList(c echo.Context) error

GetIdentityProviderList godoc

@Summary		Get a list of identity providers
@Description	*clientSecret is only available for host user
@Tags			idp
@Produce		json
@Success		200	{object}	[]IdentityProvider	"List of available identity providers"
@Failure		500	{object}	nil					"Failed to find identity provider list | Failed to find user"
@Router			/api/v1/idp [GET]

func (*APIV1Service) GetMemo added in v0.14.4

func (s *APIV1Service) GetMemo(c echo.Context) error

GetMemo godoc

@Summary	Get memo by ID
@Tags		memo
@Produce	json
@Param		memoId	path		int				true	"Memo ID"
@Success	200		{object}	[]store.Memo	"Memo list"
@Failure	400		{object}	nil				"ID is not a number: %s"
@Failure	401		{object}	nil				"Missing user in session"
@Failure	403		{object}	nil				"this memo is private only | this memo is protected, missing user in session
@Failure	404		{object}	nil				"Memo not found: %d"
@Failure	500		{object}	nil				"Failed to find memo by ID: %v | Failed to compose memo response"
@Router		/api/v1/memo/{memoId} [GET]

func (*APIV1Service) GetMemoList added in v0.14.4

func (s *APIV1Service) GetMemoList(c echo.Context) error

GetMemoList godoc

@Summary	Get a list of memos matching optional filters
@Tags		memo
@Produce	json
@Param		creatorId		query		int				false	"Creator ID"
@Param		creatorUsername	query		string			false	"Creator username"
@Param		rowStatus		query		store.RowStatus	false	"Row status"
@Param		pinned			query		bool			false	"Pinned"
@Param		tag				query		string			false	"Search for tag. Do not append #"
@Param		content			query		string			false	"Search for content"
@Param		limit			query		int				false	"Limit"
@Param		offset			query		int				false	"Offset"
@Success	200				{object}	[]store.Memo	"Memo list"
@Failure	400				{object}	nil				"Missing user to find memo"
@Failure	500				{object}	nil				"Failed to get memo display with updated ts setting value | Failed to fetch memo list | Failed to compose memo response"
@Router		/api/v1/memo [GET]

func (*APIV1Service) GetMemoRelationList added in v0.14.4

func (s *APIV1Service) GetMemoRelationList(c echo.Context) error

GetMemoRelationList godoc

@Summary	Get a list of Memo Relations
@Tags		memo-relation
@Accept		json
@Produce	json
@Param		memoId	path		int						true	"ID of memo to find relations"
@Success	200		{object}	[]store.MemoRelation	"Memo relation information list"
@Failure	400		{object}	nil						"ID is not a number: %s"
@Failure	500		{object}	nil						"Failed to list memo relations"
@Router		/api/v1/memo/{memoId}/relation [GET]

func (*APIV1Service) GetMemoStats added in v0.14.4

func (s *APIV1Service) GetMemoStats(c echo.Context) error

GetMemoStats godoc

@Summary		Get memo stats by creator ID or username
@Description	Used to generate the heatmap
@Tags			memo
@Produce		json
@Param			creatorId		query		int		false	"Creator ID"
@Param			creatorUsername	query		string	false	"Creator username"
@Success		200				{object}	[]int	"Memo createdTs list"
@Failure		400				{object}	nil		"Missing user id to find memo"
@Failure		500				{object}	nil		"Failed to get memo display with updated ts setting value | Failed to find memo list | Failed to compose memo response"
@Router			/api/v1/memo/stats [GET]

func (*APIV1Service) GetResourceList added in v0.14.4

func (s *APIV1Service) GetResourceList(c echo.Context) error

GetResourceList godoc

@Summary	Get a list of resources
@Tags		resource
@Produce	json
@Param		limit	query		int					false	"Limit"
@Param		offset	query		int					false	"Offset"
@Success	200		{object}	[]store.Resource	"Resource list"
@Failure	401		{object}	nil					"Missing user in session"
@Failure	500		{object}	nil					"Failed to fetch resource list"
@Router		/api/v1/resource [GET]

func (*APIV1Service) GetStorageList added in v0.14.4

func (s *APIV1Service) GetStorageList(c echo.Context) error

GetStorageList godoc

@Summary	Get a list of storages
@Tags		storage
@Produce	json
@Success	200	{object}	[]store.Storage	"List of storages"
@Failure	401	{object}	nil				"Missing user in session | Unauthorized"
@Failure	500	{object}	nil				"Failed to find user | Failed to convert storage"
@Router		/api/v1/storage [GET]

func (*APIV1Service) GetSystemSettingList added in v0.14.4

func (s *APIV1Service) GetSystemSettingList(c echo.Context) error

GetSystemSettingList godoc

@Summary	Get a list of system settings
@Tags		system-setting
@Produce	json
@Success	200	{object}	[]SystemSetting	"System setting list"
@Failure	401	{object}	nil				"Missing user in session | Unauthorized"
@Failure	500	{object}	nil				"Failed to find user | Failed to find system setting list"
@Router		/api/v1/system/setting [GET]

func (*APIV1Service) GetSystemStatus added in v0.14.4

func (s *APIV1Service) GetSystemStatus(c echo.Context) error

GetSystemStatus godoc

@Summary	Get system GetSystemStatus
@Tags		system
@Produce	json
@Success	200	{object}	SystemStatus	"System GetSystemStatus"
@Failure	401	{object}	nil				"Missing user in session | Unauthorized"
@Failure	500	{object}	nil				"Failed to find host user | Failed to find system setting list | Failed to unmarshal system setting customized profile value"
@Router		/api/v1/status [GET]

func (*APIV1Service) GetTagList added in v0.14.4

func (s *APIV1Service) GetTagList(c echo.Context) error

GetTagList godoc

@Summary	Get a list of tags
@Tags		tag
@Produce	json
@Success	200	{object}	[]string	"Tag list"
@Failure	400	{object}	nil			"Missing user id to find tag"
@Failure	500	{object}	nil			"Failed to find tag list"
@Router		/api/v1/tag [GET]

func (*APIV1Service) GetTagSuggestion added in v0.14.4

func (s *APIV1Service) GetTagSuggestion(c echo.Context) error

GetTagSuggestion godoc

@Summary	Get a list of tags suggested from other memos contents
@Tags		tag
@Produce	json
@Success	200	{object}	[]string	"Tag list"
@Failure	400	{object}	nil			"Missing user session"
@Failure	500	{object}	nil			"Failed to find memo list | Failed to find tag list"
@Router		/api/v1/tag/suggestion [GET]

func (*APIV1Service) GetUserByID added in v0.14.4

func (s *APIV1Service) GetUserByID(c echo.Context) error

GetUserByID godoc

@Summary	Get user by id
@Tags		user
@Produce	json
@Param		id	path		int			true	"User ID"
@Success	200	{object}	store.User	"Requested user"
@Failure	400	{object}	nil			"Malformatted user id"
@Failure	404	{object}	nil			"User not found"
@Failure	500	{object}	nil			"Failed to find user"
@Router		/api/v1/user/{id} [GET]

func (*APIV1Service) GetUserByUsername added in v0.14.4

func (s *APIV1Service) GetUserByUsername(c echo.Context) error

GetUserByUsername godoc

@Summary	Get user by username
@Tags		user
@Produce	json
@Param		username	path		string		true	"Username"
@Success	200			{object}	store.User	"Requested user"
@Failure	404			{object}	nil			"User not found"
@Failure	500			{object}	nil			"Failed to find user"
@Router		/api/v1/user/name/{username} [GET]

func (*APIV1Service) GetUserList added in v0.14.4

func (s *APIV1Service) GetUserList(c echo.Context) error

GetUserList godoc

@Summary	Get a list of users
@Tags		user
@Produce	json
@Success	200	{object}	[]store.User	"User list"
@Failure	500	{object}	nil				"Failed to fetch user list"
@Router		/api/v1/user [GET]

func (*APIV1Service) GetUserRSS added in v0.14.4

func (s *APIV1Service) GetUserRSS(c echo.Context) error

GetUserRSS godoc

@Summary	Get RSS for a user
@Tags		rss
@Produce	xml
@Param		id	path		int	true	"User ID"
@Success	200	{object}	nil	"RSS"
@Failure	400	{object}	nil	"User id is not a number"
@Failure	500	{object}	nil	"Failed to get system customized profile | Failed to find memo list | Failed to generate rss"
@Router		/u/{id}/rss.xml [GET]

func (*APIV1Service) PingSystem added in v0.14.4

func (*APIV1Service) PingSystem(c echo.Context) error

PingSystem godoc

@Summary	Ping the system
@Tags		system
@Produce	json
@Success	200	{boolean}	true	"If succeed to ping the system"
@Router		/api/v1/ping [GET]

func (*APIV1Service) Register

func (s *APIV1Service) Register(rootGroup *echo.Group)

func (*APIV1Service) SignIn added in v0.14.4

func (s *APIV1Service) SignIn(c echo.Context) error

SignIn godoc

@Summary	Sign-in to memos.
@Tags		auth
@Accept		json
@Produce	json
@Param		body	body		SignIn		true	"Sign-in object"
@Success	200		{object}	store.User	"User information"
@Failure	400		{object}	nil			"Malformatted signin request"
@Failure	401		{object}	nil			"Password login is deactivated | Incorrect login credentials, please try again"
@Failure	403		{object}	nil			"User has been archived with username %s"
@Failure	500		{object}	nil			"Failed to find system setting | Failed to unmarshal system setting | Incorrect login credentials, please try again | Failed to generate tokens | Failed to create activity"
@Router		/api/v1/auth/signin [POST]

func (*APIV1Service) SignInSSO added in v0.14.4

func (s *APIV1Service) SignInSSO(c echo.Context) error

SignInSSO godoc

@Summary	Sign-in to memos using SSO.
@Tags		auth
@Accept		json
@Produce	json
@Param		body	body		SSOSignIn	true	"SSO sign-in object"
@Success	200		{object}	store.User	"User information"
@Failure	400		{object}	nil			"Malformatted signin request"
@Failure	401		{object}	nil			"Access denied, identifier does not match the filter."
@Failure	403		{object}	nil			"User has been archived with username {username}"
@Failure	404		{object}	nil			"Identity provider not found"
@Failure	500		{object}	nil			"Failed to find identity provider | Failed to create identity provider instance | Failed to exchange token | Failed to get user info | Failed to compile identifier filter | Incorrect login credentials, please try again | Failed to generate random password | Failed to generate password hash | Failed to create user | Failed to generate tokens | Failed to create activity"
@Router		/api/v1/auth/signin/sso [POST]

func (*APIV1Service) SignOut added in v0.14.4

func (s *APIV1Service) SignOut(c echo.Context) error

SignOut godoc

@Summary	Sign-out from memos.
@Tags		auth
@Produce	json
@Success	200	{boolean}	true	"Sign-out success"
@Router		/api/v1/auth/signout [POST]

func (*APIV1Service) SignUp added in v0.14.4

func (s *APIV1Service) SignUp(c echo.Context) error

SignUp godoc

@Summary	Sign-up to memos.
@Tags		auth
@Accept		json
@Produce	json
@Param		body	body		SignUp		true	"Sign-up object"
@Success	200		{object}	store.User	"User information"
@Failure	400		{object}	nil			"Malformatted signup request | Failed to find users"
@Failure	401		{object}	nil			"signup is disabled"
@Failure	403		{object}	nil			"Forbidden"
@Failure	404		{object}	nil			"Not found"
@Failure	500		{object}	nil			"Failed to find system setting | Failed to unmarshal system setting allow signup | Failed to generate password hash | Failed to create user | Failed to generate tokens | Failed to create activity"
@Router		/api/v1/auth/signup [POST]

func (*APIV1Service) UpdateIdentityProvider added in v0.14.4

func (s *APIV1Service) UpdateIdentityProvider(c echo.Context) error

UpdateIdentityProvider godoc

@Summary	Update an identity provider by ID
@Tags		idp
@Accept		json
@Produce	json
@Param		idpId	path		int								true	"Identity Provider ID"
@Param		body	body		UpdateIdentityProviderRequest	true	"Patched identity provider information"
@Success	200		{object}	store.IdentityProvider			"Patched identity provider"
@Failure	400		{object}	nil								"ID is not a number: %s | Malformatted patch identity provider request"
@Failure	401		{object}	nil								"Missing user in session | Unauthorized
@Failure	500		{object}	nil								"Failed to find user | Failed to patch identity provider"
@Router		/api/v1/idp/{idpId} [PATCH]

func (*APIV1Service) UpdateMemo added in v0.14.4

func (s *APIV1Service) UpdateMemo(c echo.Context) error

UpdateMemo godoc

@Summary		Update a memo
@Description	Visibility can be PUBLIC, PROTECTED or PRIVATE
@Description	*You should omit fields to use their default values
@Tags			memo
@Accept			json
@Produce		json
@Param			memoId	path		int					true	"ID of memo to update"
@Param			body	body		PatchMemoRequest	true	"Patched object."
@Success		200		{object}	store.Memo			"Stored memo"
@Failure		400		{object}	nil					"ID is not a number: %s | Malformatted patch memo request | Content size overflow, up to 1MB"
@Failure		401		{object}	nil					"Missing user in session | Unauthorized"
@Failure		404		{object}	nil					"Memo not found: %d"
@Failure		500		{object}	nil					"Failed to find memo | Failed to patch memo | Failed to upsert memo resource | Failed to delete memo resource | Failed to compose memo response"
@Router			/api/v1/memo/{memoId} [PATCH]

NOTES: - It's currently possible to create phantom resources and relations. Phantom relations will trigger backend 404's when fetching memo. - Passing 0 to createdTs and updatedTs will set them to 0 in the database, which is probably unwanted.

func (*APIV1Service) UpdateResource added in v0.14.4

func (s *APIV1Service) UpdateResource(c echo.Context) error

UpdateResource godoc

@Summary	Update a resource
@Tags		resource
@Produce	json
@Param		resourceId	path		int						true	"Resource ID"
@Param		patch		body		UpdateResourceRequest	true	"Patch resource request"
@Success	200			{object}	store.Resource			"Updated resource"
@Failure	400			{object}	nil						"ID is not a number: %s | Malformatted patch resource request"
@Failure	401			{object}	nil						"Missing user in session | Unauthorized"
@Failure	404			{object}	nil						"Resource not found: %d"
@Failure	500			{object}	nil						"Failed to find resource | Failed to patch resource"
@Router		/api/v1/resource/{resourceId} [PATCH]

func (*APIV1Service) UpdateStorage added in v0.14.4

func (s *APIV1Service) UpdateStorage(c echo.Context) error

UpdateStorage godoc

@Summary	Update a storage
@Tags		storage
@Produce	json
@Param		storageId	path		int						true	"Storage ID"
@Param		patch		body		UpdateStorageRequest	true	"Patch request"
@Success	200			{object}	store.Storage			"Updated resource"
@Failure	400			{object}	nil						"ID is not a number: %s | Malformatted patch storage request | Malformatted post storage request"
@Failure	401			{object}	nil						"Missing user in session | Unauthorized"
@Failure	500			{object}	nil						"Failed to find user | Failed to patch storage | Failed to convert storage"
@Router		/api/v1/storage/{storageId} [PATCH]

func (*APIV1Service) UpdateUser added in v0.14.4

func (s *APIV1Service) UpdateUser(c echo.Context) error

UpdateUser godoc

@Summary	Update a user
@Tags		user
@Produce	json
@Param		id		path		string				true	"User ID"
@Param		patch	body		UpdateUserRequest	true	"Patch request"
@Success	200		{object}	store.User			"Updated user"
@Failure	400		{object}	nil					"ID is not a number: %s | Current session user not found with ID: %d | Malformatted patch user request | Invalid update user request"
@Failure	401		{object}	nil					"Missing user in session"
@Failure	403		{object}	nil					"Unauthorized to update user"
@Failure	500		{object}	nil					"Failed to find user | Failed to generate password hash | Failed to patch user | Failed to find userSettingList"
@Router		/api/v1/user/{id} [PATCH]

func (*APIV1Service) UploadResource added in v0.14.4

func (s *APIV1Service) UploadResource(c echo.Context) error

UploadResource godoc

@Summary	Upload resource
@Tags		resource
@Accept		multipart/form-data
@Produce	json
@Param		file	formData	file			true	"File to upload"
@Success	200		{object}	store.Resource	"Created resource"
@Failure	400		{object}	nil				"Upload file not found | File size exceeds allowed limit of %d MiB | Failed to parse upload data"
@Failure	401		{object}	nil				"Missing user in session"
@Failure	500		{object}	nil				"Failed to get uploading file | Failed to open file | Failed to save resource | Failed to create resource | Failed to create activity"
@Router		/api/v1/resource/blob [POST]

func (*APIV1Service) UpsertAccessTokenToStore added in v0.15.0

func (s *APIV1Service) UpsertAccessTokenToStore(ctx context.Context, user *store.User, accessToken string) error

type CreateIdentityProviderRequest

type CreateIdentityProviderRequest struct {
	Name             string                  `json:"name"`
	Type             IdentityProviderType    `json:"type"`
	IdentifierFilter string                  `json:"identifierFilter"`
	Config           *IdentityProviderConfig `json:"config"`
}

type CreateMemoRequest added in v0.14.0

type CreateMemoRequest struct {
	// Standard fields
	CreatorID int32  `json:"-"`
	CreatedTs *int64 `json:"createdTs"`

	// Domain specific fields
	Visibility Visibility `json:"visibility"`
	Content    string     `json:"content"`

	// Related fields
	ResourceIDList []int32                      `json:"resourceIdList"`
	RelationList   []*UpsertMemoRelationRequest `json:"relationList"`
}

type CreateResourceRequest added in v0.14.0

type CreateResourceRequest struct {
	Filename     string `json:"filename"`
	ExternalLink string `json:"externalLink"`
	Type         string `json:"type"`
}

type CreateStorageRequest added in v0.14.0

type CreateStorageRequest struct {
	Name   string         `json:"name"`
	Type   StorageType    `json:"type"`
	Config *StorageConfig `json:"config"`
}

type CreateUserRequest added in v0.14.0

type CreateUserRequest struct {
	Username string `json:"username"`
	Role     Role   `json:"role"`
	Email    string `json:"email"`
	Nickname string `json:"nickname"`
	Password string `json:"password"`
}

func (CreateUserRequest) Validate added in v0.14.0

func (create CreateUserRequest) Validate() error

type CustomizedProfile

type CustomizedProfile struct {
	// Name is the server name, default is `memos`
	Name string `json:"name"`
	// LogoURL is the url of logo image.
	LogoURL string `json:"logoUrl"`
	// Description is the server description.
	Description string `json:"description"`
	// Locale is the server default locale.
	Locale string `json:"locale"`
	// Appearance is the server default appearance.
	Appearance string `json:"appearance"`
	// ExternalURL is the external url of server. e.g. https://usermemos.com
	ExternalURL string `json:"externalUrl"`
}

CustomizedProfile is the struct definition for SystemSettingCustomizedProfileName system setting item.

type DeleteTagRequest added in v0.14.0

type DeleteTagRequest struct {
	Name string `json:"name"`
}

type FieldMapping

type FieldMapping struct {
	Identifier  string `json:"identifier"`
	DisplayName string `json:"displayName"`
	Email       string `json:"email"`
}

type FindMemoRequest added in v0.14.0

type FindMemoRequest struct {
	ID *int32

	// Standard fields
	RowStatus *RowStatus
	CreatorID *int32

	// Domain specific fields
	Pinned         *bool
	ContentSearch  []string
	VisibilityList []Visibility

	// Pagination
	Limit  *int
	Offset *int
}

type FindResourceRequest added in v0.14.0

type FindResourceRequest struct {
	ID        *int32  `json:"id"`
	CreatorID *int32  `json:"creatorId"`
	Filename  *string `json:"filename"`
}

type IdentityProvider

type IdentityProvider struct {
	ID               int32                   `json:"id"`
	Name             string                  `json:"name"`
	Type             IdentityProviderType    `json:"type"`
	IdentifierFilter string                  `json:"identifierFilter"`
	Config           *IdentityProviderConfig `json:"config"`
}

type IdentityProviderConfig

type IdentityProviderConfig struct {
	OAuth2Config *IdentityProviderOAuth2Config `json:"oauth2Config"`
}

type IdentityProviderOAuth2Config

type IdentityProviderOAuth2Config struct {
	ClientID     string        `json:"clientId"`
	ClientSecret string        `json:"clientSecret"`
	AuthURL      string        `json:"authUrl"`
	TokenURL     string        `json:"tokenUrl"`
	UserInfoURL  string        `json:"userInfoUrl"`
	Scopes       []string      `json:"scopes"`
	FieldMapping *FieldMapping `json:"fieldMapping"`
}

type IdentityProviderType

type IdentityProviderType string
const (
	IdentityProviderOAuth2Type IdentityProviderType = "OAUTH2"
)

func (IdentityProviderType) String added in v0.14.0

func (t IdentityProviderType) String() string

type Memo added in v0.14.0

type Memo struct {
	ID int32 `json:"id"`

	// Standard fields
	RowStatus RowStatus `json:"rowStatus"`
	CreatorID int32     `json:"creatorId"`
	CreatedTs int64     `json:"createdTs"`
	UpdatedTs int64     `json:"updatedTs"`

	// Domain specific fields
	DisplayTs  int64      `json:"displayTs"`
	Content    string     `json:"content"`
	Visibility Visibility `json:"visibility"`
	Pinned     bool       `json:"pinned"`

	// Related fields
	Parent          *Memo           `json:"parent"`
	CreatorName     string          `json:"creatorName"`
	CreatorUsername string          `json:"creatorUsername"`
	ResourceList    []*Resource     `json:"resourceList"`
	RelationList    []*MemoRelation `json:"relationList"`
}

type MemoOrganizer added in v0.14.0

type MemoOrganizer struct {
	MemoID int32 `json:"memoId"`
	UserID int32 `json:"userId"`
	Pinned bool  `json:"pinned"`
}

type MemoRelation added in v0.14.0

type MemoRelation struct {
	MemoID        int32            `json:"memoId"`
	RelatedMemoID int32            `json:"relatedMemoId"`
	Type          MemoRelationType `json:"type"`
}

type MemoRelationType added in v0.14.0

type MemoRelationType string
const (
	MemoRelationReference MemoRelationType = "REFERENCE"
	MemoRelationComment   MemoRelationType = "COMMENT"
)

func (MemoRelationType) String added in v0.18.0

func (t MemoRelationType) String() string

type PatchMemoRequest added in v0.14.0

type PatchMemoRequest struct {
	ID int32 `json:"-"`

	// Standard fields
	CreatedTs *int64 `json:"createdTs"`
	UpdatedTs *int64
	RowStatus *RowStatus `json:"rowStatus"`

	// Domain specific fields
	Content    *string     `json:"content"`
	Visibility *Visibility `json:"visibility"`

	// Related fields
	ResourceIDList []int32                      `json:"resourceIdList"`
	RelationList   []*UpsertMemoRelationRequest `json:"relationList"`
}

type Resource added in v0.14.0

type Resource struct {
	ID int32 `json:"id"`

	// Standard fields
	CreatorID int32 `json:"creatorId"`
	CreatedTs int64 `json:"createdTs"`
	UpdatedTs int64 `json:"updatedTs"`

	// Domain specific fields
	Filename     string `json:"filename"`
	Blob         []byte `json:"-"`
	InternalPath string `json:"-"`
	ExternalLink string `json:"externalLink"`
	Type         string `json:"type"`
	Size         int64  `json:"size"`
}

type Role

type Role string

Role is the type of a role.

const (
	// RoleHost is the HOST role.
	RoleHost Role = "HOST"
	// RoleAdmin is the ADMIN role.
	RoleAdmin Role = "ADMIN"
	// RoleUser is the USER role.
	RoleUser Role = "USER"
)

func (Role) String

func (role Role) String() string

type RowStatus

type RowStatus string

RowStatus is the status for a row.

const (
	// Normal is the status for a normal row.
	Normal RowStatus = "NORMAL"
	// Archived is the status for an archived row.
	Archived RowStatus = "ARCHIVED"
)

func (RowStatus) String

func (r RowStatus) String() string

type SSOSignIn

type SSOSignIn struct {
	IdentityProviderID int32  `json:"identityProviderId"`
	Code               string `json:"code"`
	RedirectURI        string `json:"redirectUri"`
}

type SignIn

type SignIn struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Remember bool   `json:"remember"`
}

type SignUp

type SignUp struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Storage added in v0.14.0

type Storage struct {
	ID     int32          `json:"id"`
	Name   string         `json:"name"`
	Type   StorageType    `json:"type"`
	Config *StorageConfig `json:"config"`
}

func ConvertStorageFromStore added in v0.14.0

func ConvertStorageFromStore(storage *store.Storage) (*Storage, error)

type StorageConfig added in v0.14.0

type StorageConfig struct {
	S3Config *StorageS3Config `json:"s3Config"`
}

type StorageS3Config added in v0.14.0

type StorageS3Config struct {
	EndPoint  string `json:"endPoint"`
	Path      string `json:"path"`
	Region    string `json:"region"`
	AccessKey string `json:"accessKey"`
	SecretKey string `json:"secretKey"`
	Bucket    string `json:"bucket"`
	URLPrefix string `json:"urlPrefix"`
	URLSuffix string `json:"urlSuffix"`
}

type StorageType added in v0.14.0

type StorageType string
const (
	StorageS3 StorageType = "S3"
)

func (StorageType) String added in v0.14.0

func (t StorageType) String() string

type SystemSetting

type SystemSetting struct {
	Name SystemSettingName `json:"name"`
	// Value is a JSON string with basic value.
	Value       string `json:"value"`
	Description string `json:"description"`
}

type SystemSettingName

type SystemSettingName string
const (
	// SystemSettingServerIDName is the name of server id.
	SystemSettingServerIDName SystemSettingName = "server-id"
	// SystemSettingSecretSessionName is the name of secret session.
	SystemSettingSecretSessionName SystemSettingName = "secret-session"
	// SystemSettingAllowSignUpName is the name of allow signup setting.
	SystemSettingAllowSignUpName SystemSettingName = "allow-signup"
	// SystemSettingDisablePasswordLoginName is the name of disable password login setting.
	SystemSettingDisablePasswordLoginName SystemSettingName = "disable-password-login"
	// SystemSettingDisablePublicMemosName is the name of disable public memos setting.
	SystemSettingDisablePublicMemosName SystemSettingName = "disable-public-memos"
	// SystemSettingMaxUploadSizeMiBName is the name of max upload size setting.
	SystemSettingMaxUploadSizeMiBName SystemSettingName = "max-upload-size-mib"
	// SystemSettingAdditionalStyleName is the name of additional style.
	SystemSettingAdditionalStyleName SystemSettingName = "additional-style"
	// SystemSettingAdditionalScriptName is the name of additional script.
	SystemSettingAdditionalScriptName SystemSettingName = "additional-script"
	// SystemSettingCustomizedProfileName is the name of customized server profile.
	SystemSettingCustomizedProfileName SystemSettingName = "customized-profile"
	// SystemSettingStorageServiceIDName is the name of storage service ID.
	SystemSettingStorageServiceIDName SystemSettingName = "storage-service-id"
	// SystemSettingLocalStoragePathName is the name of local storage path.
	SystemSettingLocalStoragePathName SystemSettingName = "local-storage-path"
	// SystemSettingTelegramBotTokenName is the name of Telegram Bot Token.
	SystemSettingTelegramBotTokenName SystemSettingName = "telegram-bot-token"
	// SystemSettingMemoDisplayWithUpdatedTsName is the name of memo display with updated ts.
	SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts"
	// SystemSettingAutoBackupIntervalName is the name of auto backup interval as seconds.
	SystemSettingAutoBackupIntervalName SystemSettingName = "auto-backup-interval"
)

func (SystemSettingName) String

func (key SystemSettingName) String() string

type SystemStatus added in v0.14.0

type SystemStatus struct {
	Host    *User           `json:"host"`
	Profile profile.Profile `json:"profile"`
	DBSize  int64           `json:"dbSize"`

	// System settings
	// Allow sign up.
	AllowSignUp bool `json:"allowSignUp"`
	// Disable password login.
	DisablePasswordLogin bool `json:"disablePasswordLogin"`
	// Disable public memos.
	DisablePublicMemos bool `json:"disablePublicMemos"`
	// Max upload size.
	MaxUploadSizeMiB int `json:"maxUploadSizeMiB"`
	// Auto Backup Interval.
	AutoBackupInterval int `json:"autoBackupInterval"`
	// Additional style.
	AdditionalStyle string `json:"additionalStyle"`
	// Additional script.
	AdditionalScript string `json:"additionalScript"`
	// Customized server profile, including server name and external url.
	CustomizedProfile CustomizedProfile `json:"customizedProfile"`
	// Storage service ID.
	StorageServiceID int32 `json:"storageServiceId"`
	// Local storage path.
	LocalStoragePath string `json:"localStoragePath"`
	// Memo display with updated timestamp.
	MemoDisplayWithUpdatedTs bool `json:"memoDisplayWithUpdatedTs"`
}

type Tag added in v0.14.0

type Tag struct {
	Name      string
	CreatorID int32
}

type UpdateIdentityProviderRequest

type UpdateIdentityProviderRequest struct {
	ID               int32                   `json:"-"`
	Type             IdentityProviderType    `json:"type"`
	Name             *string                 `json:"name"`
	IdentifierFilter *string                 `json:"identifierFilter"`
	Config           *IdentityProviderConfig `json:"config"`
}

type UpdateResourceRequest added in v0.14.0

type UpdateResourceRequest struct {
	Filename *string `json:"filename"`
}

type UpdateStorageRequest added in v0.14.0

type UpdateStorageRequest struct {
	Type   StorageType    `json:"type"`
	Name   *string        `json:"name"`
	Config *StorageConfig `json:"config"`
}

type UpdateUserRequest added in v0.14.0

type UpdateUserRequest struct {
	RowStatus *RowStatus `json:"rowStatus"`
	Username  *string    `json:"username"`
	Email     *string    `json:"email"`
	Nickname  *string    `json:"nickname"`
	Password  *string    `json:"password"`
	AvatarURL *string    `json:"avatarUrl"`
}

func (UpdateUserRequest) Validate added in v0.14.0

func (update UpdateUserRequest) Validate() error

type UpsertMemoOrganizerRequest added in v0.14.0

type UpsertMemoOrganizerRequest struct {
	Pinned bool `json:"pinned"`
}

type UpsertMemoRelationRequest added in v0.14.0

type UpsertMemoRelationRequest struct {
	RelatedMemoID int32            `json:"relatedMemoId"`
	Type          MemoRelationType `json:"type"`
}

type UpsertSystemSettingRequest added in v0.14.0

type UpsertSystemSettingRequest struct {
	Name        SystemSettingName `json:"name"`
	Value       string            `json:"value"`
	Description string            `json:"description"`
}

func (UpsertSystemSettingRequest) Validate added in v0.14.0

func (upsert UpsertSystemSettingRequest) Validate() error

type UpsertTagRequest added in v0.14.0

type UpsertTagRequest struct {
	Name string `json:"name"`
}

type User added in v0.14.0

type User struct {
	ID int32 `json:"id"`

	// Standard fields
	RowStatus RowStatus `json:"rowStatus"`
	CreatedTs int64     `json:"createdTs"`
	UpdatedTs int64     `json:"updatedTs"`

	// Domain specific fields
	Username     string `json:"username"`
	Role         Role   `json:"role"`
	Email        string `json:"email"`
	Nickname     string `json:"nickname"`
	PasswordHash string `json:"-"`
	AvatarURL    string `json:"avatarUrl"`
}

type Visibility

type Visibility string

Visibility is the type of a visibility.

const (
	// Public is the PUBLIC visibility.
	Public Visibility = "PUBLIC"
	// Protected is the PROTECTED visibility.
	Protected Visibility = "PROTECTED"
	// Private is the PRIVATE visibility.
	Private Visibility = "PRIVATE"
)

func (Visibility) String

func (v Visibility) String() string

Jump to

Keyboard shortcuts

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