Documentation ¶
Index ¶
- func DevMode() bool
- func MustBeAdmin(ctx context.Context) *auth.AuthContext
- type Service
- func (s *Service) Addr() net.Addr
- func (s *Service) Backup(req *proto.BackupRequest, srv proto.Management_BackupServer) error
- func (s *Service) BackupFiles(srv proto.Management_BackupFilesServer) error
- func (s *Service) CheckCommentTaskListItems(ctx context.Context, in *proto.CheckTaskListItemsRequest) (*proto.CheckTaskListItemsResponse, error)
- func (s *Service) CheckPostTaskListItems(ctx context.Context, in *proto.CheckTaskListItemsRequest) (*proto.CheckTaskListItemsResponse, error)
- func (s *Service) Config() *config.Config
- func (s *Service) CreateComment(ctx context.Context, in *proto.Comment) (*proto.Comment, error)
- func (s *Service) CreatePost(ctx context.Context, in *proto.Post) (*proto.Post, error)
- func (s *Service) DeleteComment(ctx context.Context, in *proto.DeleteCommentRequest) (*proto.DeleteCommentResponse, error)
- func (s *Service) DeletePost(ctx context.Context, in *proto.DeletePostRequest) (*empty.Empty, error)
- func (s *Service) Exporter() prometheus.Collector
- func (s *Service) FileSystem(srv proto.Management_FileSystemServer) error
- func (s *Service) GetAllCommentsCount() int64
- func (s *Service) GetComment(ctx context.Context, req *proto.GetCommentRequest) (*proto.Comment, error)
- func (s *Service) GetCommentEmailById(id int) string
- func (s *Service) GetConfig(ctx context.Context, req *proto.GetConfigRequest) (*proto.GetConfigResponse, error)
- func (s *Service) GetDefaultIntegerOption(name string, def int64) int64
- func (s *Service) GetDefaultStringOption(name string, def string) string
- func (s *Service) GetInfo(ctx context.Context, in *proto.GetInfoRequest) (*proto.GetInfoResponse, error)
- func (s *Service) GetIntegerOption(name string) (int64, error)
- func (s *Service) GetLink(ID int64) string
- func (s *Service) GetObjectTagNames(postID int64) []string
- func (s *Service) GetPlainLink(id int64) string
- func (s *Service) GetPluginStorage(name string) utils.PluginStorage
- func (s *Service) GetPost(ctx context.Context, in *proto.GetPostRequest) (*proto.Post, error)
- func (s *Service) GetPostComments(ctx context.Context, req *proto.GetPostCommentsRequest) (*proto.GetPostCommentsResponse, error)
- func (s *Service) GetPostCommentsCount(ctx context.Context, in *proto.GetPostCommentsCountRequest) (*proto.GetPostCommentsCountResponse, error)
- func (s *Service) GetPostContentCached(ctx context.Context, id int64, co *proto.PostContentOptions) (string, error)
- func (s *Service) GetPostsByTags(ctx context.Context, req *proto.GetPostsByTagsRequest) (*proto.GetPostsByTagsResponse, error)
- func (s *Service) GetStringOption(name string) (string, error)
- func (s *Service) GetTagByName(name string) *models.Tag
- func (s *Service) IncrementPostPageView(id int64)
- func (s *Service) ListAllPostsIds(ctx context.Context) ([]int32, error)
- func (s *Service) ListComments(ctx context.Context, in *proto.ListCommentsRequest) (*proto.ListCommentsResponse, error)
- func (s *Service) ListPosts(ctx context.Context, in *proto.ListPostsRequest) (*proto.ListPostsResponse, error)
- func (s *Service) ListTagsWithCount() []*models.TagWithCount
- func (s *Service) MaintenanceMode() *utils.Maintenance
- func (s *Service) MustBeAdmin(ctx context.Context) *auth.AuthContext
- func (s *Service) MustTxCall(callback func(txs *Service) error)
- func (s *Service) OpenAsset(id int64) gold_utils.WebFileSystem
- func (s *Service) Ping(ctx context.Context, in *proto.PingRequest) (*proto.PingResponse, error)
- func (s *Service) PreviewComment(ctx context.Context, in *proto.PreviewCommentRequest) (*proto.PreviewCommentResponse, error)
- func (s *Service) PreviewPost(ctx context.Context, in *proto.PreviewPostRequest) (*proto.PreviewPostResponse, error)
- func (s *Service) Restart(ctx context.Context, req *proto.RestartRequest) (*proto.RestartResponse, error)
- func (s *Service) ScheduleUpdate(ctx context.Context, req *proto.ScheduleUpdateRequest) (*proto.ScheduleUpdateResponse, error)
- func (s *Service) SearchPosts(ctx context.Context, in *proto.SearchPostsRequest) (*proto.SearchPostsResponse, error)
- func (s *Service) SetCommentPostID(ctx context.Context, in *proto.SetCommentPostIDRequest) (*proto.SetCommentPostIDResponse, error)
- func (s *Service) SetConfig(ctx context.Context, req *proto.SetConfigRequest) (*proto.SetConfigResponse, error)
- func (s *Service) SetOption(name string, value any)
- func (s *Service) SetPostStatus(ctx context.Context, in *proto.SetPostStatusRequest) (*proto.SetPostStatusResponse, error)
- func (s *Service) TestEnableRequestThrottler(enable bool)
- func (s *Service) ThemeChangedAt() time.Time
- func (s *Service) TxCall(callback func(txs *Service) error) error
- func (s *Service) UpdateComment(ctx context.Context, req *proto.UpdateCommentRequest) (*proto.Comment, error)
- func (s *Service) UpdateObjectTags(pid int64, tags []string)
- func (s *Service) UpdatePost(ctx context.Context, in *proto.UpdatePostRequest) (*proto.Post, error)
- type ToBeImplementedByRpc
- type Utils
- type With
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustBeAdmin ¶
func MustBeAdmin(ctx context.Context) *auth.AuthContext
Types ¶
type Service ¶
type Service struct { proto.AuthServer proto.TaoBlogServer proto.ManagementServer proto.SearchServer proto.UtilsServer // contains filtered or unexported fields }
Service implements IServer.
func NewService ¶
func (*Service) Backup ¶
func (s *Service) Backup(req *proto.BackupRequest, srv proto.Management_BackupServer) error
Backup ...
func (*Service) BackupFiles ¶
func (s *Service) BackupFiles(srv proto.Management_BackupFilesServer) error
func (*Service) CheckCommentTaskListItems ¶
func (s *Service) CheckCommentTaskListItems(ctx context.Context, in *proto.CheckTaskListItemsRequest) (*proto.CheckTaskListItemsResponse, error)
请保持文章和评论的代码同步。 NOTE:评论不需要检测权限,UpdateComment 会检测。
func (*Service) CheckPostTaskListItems ¶
func (s *Service) CheckPostTaskListItems(ctx context.Context, in *proto.CheckTaskListItemsRequest) (*proto.CheckTaskListItemsResponse, error)
请保持文章和评论的代码同步。
func (*Service) CreateComment ¶
创建一条评论。
前期验证项:
Author 不为空、长度不超限 Email 不为空、长度不超限 URL 可为空,若不为空,需要为正确的 URL,可不加 http 前缀,自动加 SourceType 只能为 markdown Source 不为空且不超限。
检查昵称是否被允许 检查邮箱是否被允许
检查项: post id 存在 parent 是否存在 且和 parent 的 post id 一样 root 置为 parent / parent的root IP 从请求中自动获取,忽略传入。 Date 服务端的当前时间戳,忽略传入。 Content 自动由 source 生成。
NOTE: 默认的 modified 修改时间为 0,表示从未被修改过。 NOTE: 带节流。
func (*Service) CreatePost ¶
CreatePost ...
func (*Service) DeleteComment ¶
func (s *Service) DeleteComment(ctx context.Context, in *proto.DeleteCommentRequest) (*proto.DeleteCommentResponse, error)
删除评论。
会递归地删除其所有子评论。
TODO:清理数据库的脏数据(有一部分 parent 评论已经不存在)。
func (*Service) DeletePost ¶
func (s *Service) DeletePost(ctx context.Context, in *proto.DeletePostRequest) (*empty.Empty, error)
用于删除一篇文章。 这个函数基本没怎么测试过,因为基本上只是设置为不公开。
func (*Service) Exporter ¶
func (s *Service) Exporter() prometheus.Collector
func (*Service) FileSystem ¶
func (s *Service) FileSystem(srv proto.Management_FileSystemServer) error
func (*Service) GetAllCommentsCount ¶
func (*Service) GetComment ¶
func (s *Service) GetComment(ctx context.Context, req *proto.GetCommentRequest) (*proto.Comment, error)
GetComment ... TODO perm check
func (*Service) GetCommentEmailById ¶
TODO 改个名字,这个 ID 实际上是 ephemeral。
func (*Service) GetConfig ¶
func (s *Service) GetConfig(ctx context.Context, req *proto.GetConfigRequest) (*proto.GetConfigResponse, error)
func (*Service) GetDefaultIntegerOption ¶
func (*Service) GetDefaultStringOption ¶
func (*Service) GetInfo ¶
func (s *Service) GetInfo(ctx context.Context, in *proto.GetInfoRequest) (*proto.GetInfoResponse, error)
func (*Service) GetObjectTagNames ¶
GetObjectTagNames ...
func (*Service) GetPlainLink ¶
普通链接是为了附件的 <base> 而设置,对任何主题都生效。
func (*Service) GetPluginStorage ¶
func (s *Service) GetPluginStorage(name string) utils.PluginStorage
func (*Service) GetPostComments ¶
func (s *Service) GetPostComments(ctx context.Context, req *proto.GetPostCommentsRequest) (*proto.GetPostCommentsResponse, error)
func (*Service) GetPostCommentsCount ¶
func (s *Service) GetPostCommentsCount(ctx context.Context, in *proto.GetPostCommentsCountRequest) (*proto.GetPostCommentsCountResponse, error)
GetPostCommentsCount ...
func (*Service) GetPostContentCached ¶
func (*Service) GetPostsByTags ¶
func (s *Service) GetPostsByTags(ctx context.Context, req *proto.GetPostsByTagsRequest) (*proto.GetPostsByTagsResponse, error)
GetPostsByTags gets tag posts.
func (*Service) GetTagByName ¶
GetTagByName gets a tag by Name.
func (*Service) IncrementPostPageView ¶
func (*Service) ListAllPostsIds ¶
func (*Service) ListComments ¶
func (s *Service) ListComments(ctx context.Context, in *proto.ListCommentsRequest) (*proto.ListCommentsResponse, error)
ListComments ...
func (*Service) ListPosts ¶
func (s *Service) ListPosts(ctx context.Context, in *proto.ListPostsRequest) (*proto.ListPostsResponse, error)
func (*Service) ListTagsWithCount ¶
func (s *Service) ListTagsWithCount() []*models.TagWithCount
func (*Service) MaintenanceMode ¶
func (s *Service) MaintenanceMode() *utils.Maintenance
是否在维护模式。 1. 手动进入。 2. 自动升级过程中。 https://github.com/movsb/taoblog/commit/c4428d7
func (*Service) MustBeAdmin ¶
func (s *Service) MustBeAdmin(ctx context.Context) *auth.AuthContext
从 Context 中取出用户并且必须为 Admin/System,否则 panic。
func (*Service) MustTxCall ¶
MustTxCall ...
func (*Service) OpenAsset ¶
func (s *Service) OpenAsset(id int64) gold_utils.WebFileSystem
func (*Service) Ping ¶
func (s *Service) Ping(ctx context.Context, in *proto.PingRequest) (*proto.PingResponse, error)
Ping ...
func (*Service) PreviewComment ¶
func (s *Service) PreviewComment(ctx context.Context, in *proto.PreviewCommentRequest) (*proto.PreviewCommentResponse, error)
func (*Service) PreviewPost ¶
func (s *Service) PreviewPost(ctx context.Context, in *proto.PreviewPostRequest) (*proto.PreviewPostResponse, error)
TODO 文章编号可能是 0️⃣
func (*Service) Restart ¶
func (s *Service) Restart(ctx context.Context, req *proto.RestartRequest) (*proto.RestartResponse, error)
func (*Service) ScheduleUpdate ¶
func (s *Service) ScheduleUpdate(ctx context.Context, req *proto.ScheduleUpdateRequest) (*proto.ScheduleUpdateResponse, error)
func (*Service) SearchPosts ¶
func (s *Service) SearchPosts(ctx context.Context, in *proto.SearchPostsRequest) (*proto.SearchPostsResponse, error)
func (*Service) SetCommentPostID ¶
func (s *Service) SetCommentPostID(ctx context.Context, in *proto.SetCommentPostIDRequest) (*proto.SetCommentPostIDResponse, error)
SetCommentPostID 把某条顶级评论及其子评论转移到另一篇文章下 TODO:禁止转移内容中引用了当前文章资源的评论,或者处理这个问题。
func (*Service) SetConfig ¶
func (s *Service) SetConfig(ctx context.Context, req *proto.SetConfigRequest) (*proto.SetConfigResponse, error)
func (*Service) SetPostStatus ¶
func (s *Service) SetPostStatus(ctx context.Context, in *proto.SetPostStatusRequest) (*proto.SetPostStatusResponse, error)
SetPostStatus sets post status. 会总是更新 LastCommentedAt 时间。 TODO 改成内部调用 UpdatePost,并检查 status 是否合法。
func (*Service) TestEnableRequestThrottler ¶
测试的时候需要禁用限流器。
func (*Service) ThemeChangedAt ¶
func (*Service) UpdateComment ¶
func (s *Service) UpdateComment(ctx context.Context, req *proto.UpdateCommentRequest) (*proto.Comment, error)
更新评论。
NOTE:只支持更新评论内容。 NOTE:带上时间戳,防止异地多次更新的冲突(太严格了吧!) NOTE:带节流。
func (*Service) UpdateObjectTags ¶
UpdateObjectTags ... 会自动去重。
func (*Service) UpdatePost ¶
UpdatePost ... 需要携带版本号,像评论一样。
type ToBeImplementedByRpc ¶
type ToBeImplementedByRpc interface { ListAllPostsIds(ctx context.Context) ([]int32, error) GetDefaultIntegerOption(name string, def int64) int64 GetLink(ID int64) string GetPlainLink(ID int64) string Config() *config.Config ListTagsWithCount() []*models.TagWithCount IncrementPostPageView(id int64) ThemeChangedAt() time.Time GetCommentEmailById(id int) string }
type Utils ¶
type Utils struct { proto.UnimplementedUtilsServer RemoteDialer atomic.Pointer[dialers.RemoteDialerManager] // contains filtered or unexported fields }
func NewUtils ¶
func NewUtils(instantNotifier notify.InstantNotifier) *Utils
func (*Utils) DialRemote ¶
func (u *Utils) DialRemote(s proto.Utils_DialRemoteServer) error
func (*Utils) FormatTime ¶
func (u *Utils) FormatTime(ctx context.Context, in *proto.FormatTimeRequest) (*proto.FormatTimeResponse, error)
func (*Utils) InstantNotify ¶
func (u *Utils) InstantNotify(ctx context.Context, in *proto.InstantNotifyRequest) (*proto.InstantNotifyResponse, error)
type With ¶
type With func(s *Service)
func WithInstantNotifier ¶
func WithInstantNotifier(instantNotifier notify.InstantNotifier) With
func WithRequestThrottler ¶
func WithRequestThrottler(throttler grpc.UnaryServerInterceptor) With
请求节流器。