Documentation ¶
Overview ¶
# Some idea: # Set a trash bin and then permanently deleted? -- can use the build-in delete(just mark)
Implement notes: Use api to get information, DON't use database directly But cleanng work will do directly with database anyway. Investigate API, to find the database operation
Mattermost job system memo v5.35
Jobserver: Like a platform providing tools Watch: Poll and notify Works every 15 secs Check the job DB and find any pending jobs send the job to specific job channel( return from Worker.JobChannel()) Scheduler: Schedule the next exection time Put the job in DB as pending status, this must be implemented in ScheduleJob() using Jobserver.CreateJob Worker: Execute job. Wait until any job put in JobChannel()
Initialization flow: Server cmd - run-server:
a.NewServer s.initEntprise s.initJobs fakeapp.initServer a.initEnterprise a.initJobs a.srv.jobs.initWorks() a.srv.jobs.MakeWatcher() a.src.jobs.initSchedules() s.runjobs s.js.StartWorkers() workers.start() + watch.start() s.js.StartSchedulers()
Index ¶
- Variables
- type Channel
- type ChannelRes
- type Channels
- type ChannelsRes
- type Days
- type ExpanedPolicyWithId
- type File
- type Options
- type Policy
- type PolicyCtrl
- type PolicyService
- type PruneService
- type PruneStore
- type Result
- type Settings
- type Stats
- type StatsFile
- type Sweep
- type SweepFiles
- type Switch
- type Team
- type TeamRes
- type Teams
- type TeamsRes
- type UserRes
- type Users
- type UsersRes
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ChannelsRes ¶
type ChannelsRes map[string]ChannelRes
type ExpanedPolicyWithId ¶
type ExpanedPolicyWithId Policy
type PolicyCtrl ¶
type PolicyCtrl struct { Policy Policy // contains filtered or unexported fields }
func (*PolicyCtrl) ExpandPolicyAndNormalize ¶
func (pctl *PolicyCtrl) ExpandPolicyAndNormalize() (*ExpanedPolicyWithId, error)
ExpandPolicyAndNormalize expand the policy to individual unit and normalize the result. Normalized result fills all the field settings, which means all the teams/channels/user which will be pruned should be filled with all fields.
Expandition flow: - If current Persist* is not nil and false, use the Day* vale( Day* must be not zero) - if current Persist* is not nil and true, set Persist* = true, leave Day* nil - if current Perist* is nil, look levels up until the first Perist* is not nil -- if Perist* == true, set true, and leave Day* nil -- if Perist* == false, set false, and set Days* as that value( must not be zero) -- if all Persit* is true, don't append the result
Note: - Result is is a map with Id( not name)
func (*PolicyCtrl) GetPolicy ¶
func (pctl *PolicyCtrl) GetPolicy() Policy
func (*PolicyCtrl) LoadFromConfig ¶
func (pctl *PolicyCtrl) LoadFromConfig() error
func (*PolicyCtrl) LoadFromYaml ¶
func (pctl *PolicyCtrl) LoadFromYaml(yamlStr string) error
LoadFromYaml load and normalize the result.
For root node, nil means false, should create a node. For non-root node, nil means look levels up for that field.
If Days* is inputed but Persist* is nil, set Persist* = false If Days* is inputed(!= nil, or value != 0) but Persist* == true, non-sense, error If Days* is not inputed(nil), but Persis* == false, error
type PolicyService ¶
type PolicyService interface { LoadFromConfig() error LoadFromYaml(yamlStr string) error ExpandPolicyAndNormalize() (*ExpanedPolicyWithId, error) GetPolicy() Policy }
func NewPolicyService ¶
func NewPolicyService(apiClient *pluginapi.Client, cl config.Service, pstore PruneStore) PolicyService
type PruneService ¶
func NewPruneService ¶
func NewPruneService(ps PruneStore, api *pluginapi.Client, cl config.Service, logger bot.Logger, poster bot.Poster) PruneService
type PruneStore ¶
type PruneStore interface { CutThreads(chid string, opt Options) ([]*model.Post, error) CutRoots(chid string, opt Options) ([]*model.Post, error) CutDeletedRoots(chid string, opt Options) ([]*model.Post, error) SweepThreads() ([]*model.Post, error) SweepReactions() ([]*model.Reaction, error) SweepPreferences() ([]*model.Preference, error) SweepFileInfos() ([]*model.FileInfo, error) SweepFiles() ([]File, error) //copied from mattermost-server channel store( MM_ChannelStore_GetAll) GetAllChannelsForTeam(teamID string) ([]*model.Channel, error) }
type Settings ¶
type Settings struct { PersistNormal *Switch `yaml:"persist_normal"` PersistDeleted *Switch `yaml:"persist_deleted"` DaysOfPrune *Days `yaml:"days_of_prune"` DaysOfDeleted *Days `yaml:"days_of_deleted"` //OnlyThreadPruned prune only threads. //context free of Persist* OnlyThreadPruned *Switch `yaml:"only_thread"` }
if nil, use Settings 1 level up if root's setting is nil, no deletetion is default if Persist* = true, then Days* will always be 0. they are paires
Deleted posts and Non-Deleted posts are seperated.
if OnlyThreadPruned then prune only thread else only roots