sudoapi

package
v0.0.0-...-5733806 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ImportantUpdatesWebhook = config.GenFlag[string]("admin.important_webhook", "", "Webhook URL for audit log-level events")
	VerboseUpdatesWebhook   = config.GenFlag[string]("admin.verbose_webhook", "", "Webhook URL for verbose platform information")
)
View Source
var (
	ErrNoUpdates       = kilonova.ErrNoUpdates
	ErrMissingRequired = kilonova.ErrMissingRequired

	ErrNotFound     = kilonova.ErrNotFound
	ErrUnknownError = kilonova.ErrUnknownError
)
View Source
var (
	SubForEveryoneConfig = config.GenFlag("behavior.everyone_subs", true, "Anyone can view others' source code")

	PastesEnabled = config.GenFlag("feature.pastes.enabled", true, "Pastes")
)
View Source
var (
	CanChangeNames = config.GenFlag("feature.username_changes.enabled", true, "Anyone can change their usernames")
)
View Source
var (
	SignupEnabled = config.GenFlag("feature.platform.signup", true, "Manual signup")
)

Functions

func InitializeBaseAPI

func InitializeBaseAPI(ctx context.Context) (*BaseAPI, *StatusError)

Types

type BaseAPI

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

func GetBaseAPI

func GetBaseAPI(db *db.DB, manager kilonova.DataStore, mailer kilonova.Mailer) *BaseAPI

func (*BaseAPI) AddContestEditor

func (s *BaseAPI) AddContestEditor(ctx context.Context, pbid int, uid int) *StatusError

func (*BaseAPI) AddContestTester

func (s *BaseAPI) AddContestTester(ctx context.Context, pbid int, uid int) *StatusError

func (*BaseAPI) AddDonation

func (s *BaseAPI) AddDonation(ctx context.Context, donation *kilonova.Donation) *kilonova.StatusError

func (*BaseAPI) AddProblemEditor

func (s *BaseAPI) AddProblemEditor(ctx context.Context, pbid int, uid int) *StatusError

func (*BaseAPI) AddProblemViewer

func (s *BaseAPI) AddProblemViewer(ctx context.Context, pbid int, uid int) *StatusError

func (*BaseAPI) AnswerContestQuestion

func (s *BaseAPI) AnswerContestQuestion(ctx context.Context, id int, text string) *StatusError

func (*BaseAPI) Attachment

func (s *BaseAPI) Attachment(ctx context.Context, id int) (*kilonova.Attachment, *StatusError)

func (*BaseAPI) AttachmentData

func (s *BaseAPI) AttachmentData(ctx context.Context, id int) ([]byte, *StatusError)

func (*BaseAPI) AttemptedProblems

func (s *BaseAPI) AttemptedProblems(ctx context.Context, user *kilonova.UserBrief, lookingUser *kilonova.UserBrief) ([]*kilonova.ScoredProblem, *StatusError)

Deprecated. TODO: Remove

func (*BaseAPI) BlogPost

func (s *BaseAPI) BlogPost(ctx context.Context, id int) (*kilonova.BlogPost, *StatusError)

func (*BaseAPI) BlogPostAttByName

func (s *BaseAPI) BlogPostAttByName(ctx context.Context, postID int, name string) (*kilonova.Attachment, *StatusError)

func (*BaseAPI) BlogPostAttachment

func (s *BaseAPI) BlogPostAttachment(ctx context.Context, postID, attachmentID int) (*kilonova.Attachment, *StatusError)

func (*BaseAPI) BlogPostAttachments

func (s *BaseAPI) BlogPostAttachments(ctx context.Context, postID int) ([]*kilonova.Attachment, *StatusError)

func (*BaseAPI) BlogPostBySlug

func (s *BaseAPI) BlogPostBySlug(ctx context.Context, slug string) (*kilonova.BlogPost, *StatusError)

func (*BaseAPI) BlogPostDescVariants

func (s *BaseAPI) BlogPostDescVariants(ctx context.Context, problemID int, getPrivate bool) ([]*kilonova.StatementVariant, *StatusError)

func (*BaseAPI) BlogPosts

func (s *BaseAPI) BlogPosts(ctx context.Context, filter kilonova.BlogPostFilter) ([]*kilonova.BlogPost, *StatusError)

func (*BaseAPI) CanJoinContest

func (s *BaseAPI) CanJoinContest(c *kilonova.Contest) bool

func (*BaseAPI) CanSubmitInContest

func (s *BaseAPI) CanSubmitInContest(user *kilonova.UserBrief, c *kilonova.Contest) bool

CanSubmitInContest checks if the user is either a contestant and the contest is running, or a tester/editor/admin. Ended contests cannot have submissions created by anyone Also, USACO-style contests are fun to handle...

func (*BaseAPI) CanViewContestProblems

func (s *BaseAPI) CanViewContestProblems(ctx context.Context, user *kilonova.UserBrief, contest *kilonova.Contest) bool

CanViewContestProblems checks if the user can see a contest's problems. Note that this does not neccesairly mean that he can submit in them! A problem may be viewable because the contest is running and visible, but only registered people should submit It's a bit frustrating but it's an important distinction If you think about it, all submitters can view problems, but not all problem viewers can submit

func (*BaseAPI) CanViewTests

func (s *BaseAPI) CanViewTests(user *kilonova.UserBrief, problem *kilonova.Problem) bool

func (*BaseAPI) CheckPasswordResetRequest

func (s *BaseAPI) CheckPasswordResetRequest(ctx context.Context, rid string) bool

func (*BaseAPI) CheckValidPassword

func (s *BaseAPI) CheckValidPassword(pwd string) *StatusError

func (*BaseAPI) CheckValidUsername

func (s *BaseAPI) CheckValidUsername(name string) *StatusError

func (*BaseAPI) CheckVerificationEmail

func (s *BaseAPI) CheckVerificationEmail(ctx context.Context, vid string) bool

func (*BaseAPI) CleanupSubTasks

func (s *BaseAPI) CleanupSubTasks(ctx context.Context, problemID int) *StatusError

CleanupSubtasks removes all subtasks from a problem that do not have any tests

func (*BaseAPI) Close

func (s *BaseAPI) Close() *StatusError

func (*BaseAPI) ConfirmVerificationEmail

func (s *BaseAPI) ConfirmVerificationEmail(vid string, user *kilonova.UserBrief) *StatusError

func (*BaseAPI) Contest

func (s *BaseAPI) Contest(ctx context.Context, id int) (*kilonova.Contest, *StatusError)

func (*BaseAPI) ContestAnnouncement

func (s *BaseAPI) ContestAnnouncement(ctx context.Context, id int) (*kilonova.ContestAnnouncement, *StatusError)

func (*BaseAPI) ContestAnnouncements

func (s *BaseAPI) ContestAnnouncements(ctx context.Context, contestID int) ([]*kilonova.ContestAnnouncement, *StatusError)

func (*BaseAPI) ContestLeaderboard

func (s *BaseAPI) ContestLeaderboard(ctx context.Context, contest *kilonova.Contest, freezeTime *time.Time) (*kilonova.ContestLeaderboard, *StatusError)

func (*BaseAPI) ContestMaxScore

func (s *BaseAPI) ContestMaxScore(ctx context.Context, uid, pbID, contestID int, freezeTime *time.Time) decimal.Decimal

func (*BaseAPI) ContestProblem

func (s *BaseAPI) ContestProblem(ctx context.Context, contest *kilonova.Contest, lookingUser *kilonova.UserBrief, problemID int) (*kilonova.Problem, *StatusError)

func (*BaseAPI) ContestProblems

func (s *BaseAPI) ContestProblems(ctx context.Context, contest *kilonova.Contest, lookingUser *kilonova.UserBrief) ([]*kilonova.ScoredProblem, *StatusError)

NOTE: This function is assumed to be used only for the looking user. As such, freeze times are bypassed and the current scores are shown.

func (*BaseAPI) ContestQuestion

func (s *BaseAPI) ContestQuestion(ctx context.Context, id int) (*kilonova.ContestQuestion, *StatusError)

func (*BaseAPI) ContestQuestions

func (s *BaseAPI) ContestQuestions(ctx context.Context, contestID int) ([]*kilonova.ContestQuestion, *StatusError)

func (*BaseAPI) ContestRegistration

func (s *BaseAPI) ContestRegistration(ctx context.Context, contestID, userID int) (*kilonova.ContestRegistration, *StatusError)

func (*BaseAPI) ContestRegistrationCount

func (s *BaseAPI) ContestRegistrationCount(ctx context.Context, contestID int) (int, *StatusError)

func (*BaseAPI) ContestRegistrations

func (s *BaseAPI) ContestRegistrations(ctx context.Context, contestID int, fuzzyName *string, limit, offset int) ([]*kilonova.ContestRegistration, *StatusError)

func (*BaseAPI) ContestUserQuestions

func (s *BaseAPI) ContestUserQuestions(ctx context.Context, contestID, userID int) ([]*kilonova.ContestQuestion, *StatusError)

func (*BaseAPI) CountBlogPosts

func (s *BaseAPI) CountBlogPosts(ctx context.Context, filter kilonova.BlogPostFilter) (int, *StatusError)

func (*BaseAPI) CountUsers

func (s *BaseAPI) CountUsers(ctx context.Context, filter kilonova.UserFilter) (int, *StatusError)

func (*BaseAPI) CreateBlogPost

func (s *BaseAPI) CreateBlogPost(ctx context.Context, title string, author *kilonova.UserBrief) (int, string, *StatusError)

func (*BaseAPI) CreateBlogPostAttachment

func (s *BaseAPI) CreateBlogPostAttachment(ctx context.Context, att *kilonova.Attachment, postID int, r io.Reader, authorID *int) *StatusError

func (*BaseAPI) CreateContest

func (s *BaseAPI) CreateContest(ctx context.Context, name string, author *UserBrief) (int, *StatusError)

func (*BaseAPI) CreateContestAnnouncement

func (s *BaseAPI) CreateContestAnnouncement(ctx context.Context, contestID int, text string) (int, *StatusError)

func (*BaseAPI) CreateContestQuestion

func (s *BaseAPI) CreateContestQuestion(ctx context.Context, contestID, authorID int, text string) (int, *StatusError)

func (*BaseAPI) CreatePaste

func (s *BaseAPI) CreatePaste(ctx context.Context, sub *kilonova.Submission, user *kilonova.UserBrief) (string, *StatusError)

func (*BaseAPI) CreateProblem

func (s *BaseAPI) CreateProblem(ctx context.Context, title string, author *UserBrief, consoleInput bool) (*kilonova.Problem, *StatusError)

CreateProblem is the simple way of creating a new problem. Just provide a title, an author and the type of input. The other stuff will be automatically set for sensible defaults.

func (*BaseAPI) CreateProblemAttachment

func (s *BaseAPI) CreateProblemAttachment(ctx context.Context, att *kilonova.Attachment, problemID int, r io.Reader, authorID *int) *StatusError

func (*BaseAPI) CreateProblemList

func (s *BaseAPI) CreateProblemList(ctx context.Context, pblist *kilonova.ProblemList) *StatusError

func (*BaseAPI) CreateSession

func (s *BaseAPI) CreateSession(ctx context.Context, uid int) (string, *StatusError)

func (*BaseAPI) CreateSubTask

func (s *BaseAPI) CreateSubTask(ctx context.Context, subtask *kilonova.SubTask) *StatusError

func (*BaseAPI) CreateSubmission

func (s *BaseAPI) CreateSubmission(ctx context.Context, author *UserBrief, problem *kilonova.Problem, code string, lang eval.Language, contestID *int, bypassSubCount bool) (int, *StatusError)

CreateSubmission produces a new submission and also creates the necessary subtests

func (*BaseAPI) CreateTag

func (s *BaseAPI) CreateTag(ctx context.Context, name string, tagType kilonova.TagType) (int, *StatusError)

func (*BaseAPI) CreateTest

func (s *BaseAPI) CreateTest(ctx context.Context, test *kilonova.Test) *StatusError

func (*BaseAPI) DelAttachmentRender

func (s *BaseAPI) DelAttachmentRender(attID int) error

func (*BaseAPI) DeleteBlogPost

func (s *BaseAPI) DeleteBlogPost(ctx context.Context, post *kilonova.BlogPost) *StatusError

func (*BaseAPI) DeleteBlogPostAtts

func (s *BaseAPI) DeleteBlogPostAtts(ctx context.Context, postID int, attIDs []int) (int, *StatusError)

func (*BaseAPI) DeleteContest

func (s *BaseAPI) DeleteContest(ctx context.Context, contest *kilonova.Contest) *StatusError

func (*BaseAPI) DeleteContestAnnouncement

func (s *BaseAPI) DeleteContestAnnouncement(ctx context.Context, announcementID int) *StatusError

func (*BaseAPI) DeletePaste

func (s *BaseAPI) DeletePaste(ctx context.Context, id string) *StatusError

func (*BaseAPI) DeleteProblem

func (s *BaseAPI) DeleteProblem(ctx context.Context, problem *kilonova.Problem) *StatusError

func (*BaseAPI) DeleteProblemAtts

func (s *BaseAPI) DeleteProblemAtts(ctx context.Context, problemID int, attIDs []int) (int, *StatusError)

func (*BaseAPI) DeleteProblemList

func (s *BaseAPI) DeleteProblemList(ctx context.Context, id int) *StatusError

func (*BaseAPI) DeleteSubTask

func (s *BaseAPI) DeleteSubTask(ctx context.Context, subtaskID int) *StatusError

func (*BaseAPI) DeleteSubTasks

func (s *BaseAPI) DeleteSubTasks(ctx context.Context, problemID int) *StatusError

func (*BaseAPI) DeleteSubmission

func (s *BaseAPI) DeleteSubmission(ctx context.Context, subID int) *StatusError

func (*BaseAPI) DeleteTag

func (s *BaseAPI) DeleteTag(ctx context.Context, tag *kilonova.Tag) *StatusError

func (*BaseAPI) DeleteTest

func (s *BaseAPI) DeleteTest(ctx context.Context, id int) *StatusError

Please note that this function does not properly ensure that subtasks would be cleaned up afterwards. This is left as an exercise to the caller

func (*BaseAPI) DeleteTests

func (s *BaseAPI) DeleteTests(ctx context.Context, problemID int) *StatusError

func (*BaseAPI) DeleteUser

func (s *BaseAPI) DeleteUser(ctx context.Context, user *kilonova.UserBrief) *StatusError

func (*BaseAPI) Donations

func (s *BaseAPI) Donations(ctx context.Context) ([]*kilonova.Donation, *kilonova.StatusError)

func (*BaseAPI) ExtendSession

func (s *BaseAPI) ExtendSession(ctx context.Context, sid string) (time.Time, *StatusError)

func (*BaseAPI) FinalizePasswordReset

func (s *BaseAPI) FinalizePasswordReset(ctx context.Context, rid string, newPassword string) *StatusError

func (*BaseAPI) FullProblemList

func (s *BaseAPI) FullProblemList(ctx context.Context, listID int, user *kilonova.UserBrief, lookingUser *kilonova.UserBrief) (*FullProblemList, *StatusError)

FullProblemList returns an entire problem list DAG. The operation will probably be slow. Note that recursion to a "higher" level is automatically stripped

func (*BaseAPI) FullSubmission

func (s *BaseAPI) FullSubmission(ctx context.Context, subid int) (*FullSubmission, *StatusError)

FullSubmission gets the submission regardless of if there is a user watching or not

func (*BaseAPI) GenerateUser

func (s *BaseAPI) GenerateUser(ctx context.Context, uname, pwd, lang string, theme kilonova.PreferredTheme, displayName *string) (*kilonova.UserFull, *StatusError)

TODO: displayName probably doesn't have to be *string, can be just string, but this was implemented quickly

func (*BaseAPI) GetAttachmentRender

func (s *BaseAPI) GetAttachmentRender(attID int) (io.ReadSeekCloser, error)

func (*BaseAPI) GetAuditLogs

func (s *BaseAPI) GetAuditLogs(ctx context.Context, count int, offset int) ([]*kilonova.AuditLog, *StatusError)
func (s *BaseAPI) GetGravatarLink(user *kilonova.UserFull, size int) string

func (*BaseAPI) GetLogCount

func (s *BaseAPI) GetLogCount(ctx context.Context) (int, *StatusError)

func (*BaseAPI) GetPwdResetRequestUser

func (s *BaseAPI) GetPwdResetRequestUser(ctx context.Context, rid string) (int, *StatusError)

func (*BaseAPI) GetSessCookie

func (s *BaseAPI) GetSessCookie(r *http.Request) string

func (*BaseAPI) GetSession

func (s *BaseAPI) GetSession(ctx context.Context, sid string) (int, *StatusError)

Please note that, when unauthed, GetSession will return a session with UserID set to -1

func (*BaseAPI) GetVerificationUser

func (s *BaseAPI) GetVerificationUser(ctx context.Context, vid string) (int, *StatusError)

func (*BaseAPI) HasAttachmentRender

func (s *BaseAPI) HasAttachmentRender(attID int) bool

func (*BaseAPI) InvalidateAllAttachments

func (s *BaseAPI) InvalidateAllAttachments() error

func (*BaseAPI) IsAdmin

func (s *BaseAPI) IsAdmin(user *kilonova.UserBrief) bool

func (*BaseAPI) IsAuthed

func (s *BaseAPI) IsAuthed(user *kilonova.UserBrief) bool

func (*BaseAPI) IsBlogPostEditor

func (s *BaseAPI) IsBlogPostEditor(user *kilonova.UserBrief, post *kilonova.BlogPost) bool

func (*BaseAPI) IsBlogPostVisible

func (s *BaseAPI) IsBlogPostVisible(user *kilonova.UserBrief, post *kilonova.BlogPost) bool

NOTE: This must be in sync with the visible_posts PSQL function

func (*BaseAPI) IsContestEditor

func (s *BaseAPI) IsContestEditor(user *kilonova.UserBrief, contest *kilonova.Contest) bool

func (*BaseAPI) IsContestTester

func (s *BaseAPI) IsContestTester(user *kilonova.UserBrief, contest *kilonova.Contest) bool

Tester = Testers + Editors + Admins

func (*BaseAPI) IsContestVisible

func (s *BaseAPI) IsContestVisible(user *kilonova.UserBrief, contest *kilonova.Contest) bool

func (*BaseAPI) IsPasteEditor

func (s *BaseAPI) IsPasteEditor(paste *kilonova.SubmissionPaste, user *kilonova.UserBrief) bool

func (*BaseAPI) IsProblemEditor

func (s *BaseAPI) IsProblemEditor(user *kilonova.UserBrief, problem *kilonova.Problem) bool

func (*BaseAPI) IsProblemFullyVisible

func (s *BaseAPI) IsProblemFullyVisible(user *kilonova.UserBrief, problem *kilonova.Problem) bool

Full visibility is currently used for:

  • problem statistics;
  • submission code visibility;
  • problem archive availability (however, some stuff like private attachments or tests depend on further privileges).

func (*BaseAPI) IsProblemVisible

func (s *BaseAPI) IsProblemVisible(user *kilonova.UserBrief, problem *kilonova.Problem) bool

func (*BaseAPI) IsProposer

func (s *BaseAPI) IsProposer(user *kilonova.UserBrief) bool

func (*BaseAPI) IsSubmissionEditor

func (s *BaseAPI) IsSubmissionEditor(sub *kilonova.Submission, user *kilonova.UserBrief) bool

func (*BaseAPI) KickUserFromContest

func (s *BaseAPI) KickUserFromContest(ctx context.Context, contestID, userID int) *StatusError

func (*BaseAPI) LogInfo

func (s *BaseAPI) LogInfo(ctx context.Context, msg string, args ...any)

func (*BaseAPI) LogSystemAction

func (s *BaseAPI) LogSystemAction(ctx context.Context, msg string, args ...any)

func (*BaseAPI) LogToDiscord

func (s *BaseAPI) LogToDiscord(ctx context.Context, msg string, args ...any)

func (*BaseAPI) LogUserAction

func (s *BaseAPI) LogUserAction(ctx context.Context, msg string, args ...any)

func (*BaseAPI) LogVerbose

func (s *BaseAPI) LogVerbose(ctx context.Context, msg string, args ...any)

func (*BaseAPI) Login

func (s *BaseAPI) Login(ctx context.Context, uname, pwd string) (*kilonova.UserFull, *StatusError)

func (*BaseAPI) MaxScore

func (s *BaseAPI) MaxScore(ctx context.Context, uid, pbID int) decimal.Decimal

func (*BaseAPI) MaxScoreSubID

func (s *BaseAPI) MaxScoreSubID(ctx context.Context, uid, pbID int) (int, *StatusError)

func (*BaseAPI) MaximumScoreSubTaskTests

func (s *BaseAPI) MaximumScoreSubTaskTests(ctx context.Context, problemID, userID int, contestID *int) ([]*kilonova.SubTest, *StatusError)

func (*BaseAPI) MaximumScoreSubTasks

func (s *BaseAPI) MaximumScoreSubTasks(ctx context.Context, problemID, userID int, contestID *int) ([]*kilonova.SubmissionSubTask, *StatusError)

func (*BaseAPI) MergeTags

func (s *BaseAPI) MergeTags(ctx context.Context, original int, toReplace []int) *StatusError

original - the OG that will remain after the merge toReplace - the one that will be replaced

func (*BaseAPI) NextVID

func (s *BaseAPI) NextVID(ctx context.Context, problemID int) int

func (*BaseAPI) NumSolvedFromPblist

func (s *BaseAPI) NumSolvedFromPblist(ctx context.Context, listID int, userID int) (int, *StatusError)

func (*BaseAPI) NumSolvedFromPblists

func (s *BaseAPI) NumSolvedFromPblists(ctx context.Context, listIDs []int, user *kilonova.UserBrief) (map[int]int, *StatusError)

func (*BaseAPI) PblistChildrenLists

func (s *BaseAPI) PblistChildrenLists(ctx context.Context, problemListID int) ([]*kilonova.ProblemList, *StatusError)

func (*BaseAPI) PblistParentLists

func (s *BaseAPI) PblistParentLists(ctx context.Context, problemListID int) ([]*kilonova.ProblemList, *StatusError)

func (*BaseAPI) Problem

func (s *BaseAPI) Problem(ctx context.Context, id int) (*kilonova.Problem, *StatusError)

When editing Problem, please edit ScoredProblem as well

func (*BaseAPI) ProblemAttByName

func (s *BaseAPI) ProblemAttByName(ctx context.Context, problemID int, name string) (*kilonova.Attachment, *StatusError)

func (*BaseAPI) ProblemAttDataByName

func (s *BaseAPI) ProblemAttDataByName(ctx context.Context, problemID int, name string) ([]byte, *StatusError)

func (*BaseAPI) ProblemAttachment

func (s *BaseAPI) ProblemAttachment(ctx context.Context, problemID, attachmentID int) (*kilonova.Attachment, *StatusError)

func (*BaseAPI) ProblemAttachments

func (s *BaseAPI) ProblemAttachments(ctx context.Context, problemID int) ([]*kilonova.Attachment, *StatusError)

func (*BaseAPI) ProblemChecklist

func (s *BaseAPI) ProblemChecklist(ctx context.Context, pbid int) (*kilonova.ProblemChecklist, *StatusError)

func (*BaseAPI) ProblemDescVariants

func (s *BaseAPI) ProblemDescVariants(ctx context.Context, problemID int, getPrivate bool) ([]*kilonova.StatementVariant, *StatusError)

func (*BaseAPI) ProblemEditors

func (s *BaseAPI) ProblemEditors(ctx context.Context, pbid int) ([]*kilonova.UserBrief, *StatusError)

func (*BaseAPI) ProblemList

func (s *BaseAPI) ProblemList(ctx context.Context, id int) (*kilonova.ProblemList, *StatusError)

func (*BaseAPI) ProblemListByName

func (s *BaseAPI) ProblemListByName(ctx context.Context, name string) (*kilonova.ProblemList, *StatusError)

func (*BaseAPI) ProblemListProblems

func (s *BaseAPI) ProblemListProblems(ctx context.Context, ids []int, lookingUser *kilonova.UserBrief) ([]*kilonova.ScoredProblem, *StatusError)

Returns a list of problems in the slice's order

func (*BaseAPI) ProblemLists

func (s *BaseAPI) ProblemLists(ctx context.Context, filter kilonova.ProblemListFilter) ([]*kilonova.ProblemList, *StatusError)

func (*BaseAPI) ProblemParentLists

func (s *BaseAPI) ProblemParentLists(ctx context.Context, problemID int, showHidable bool) ([]*kilonova.ProblemList, *StatusError)

func (*BaseAPI) ProblemRunningContests

func (s *BaseAPI) ProblemRunningContests(ctx context.Context, problemID int) ([]*kilonova.Contest, *StatusError)

func (*BaseAPI) ProblemSettings

func (s *BaseAPI) ProblemSettings(ctx context.Context, problemID int) (*kilonova.ProblemEvalSettings, *StatusError)

func (*BaseAPI) ProblemStatistics

func (s *BaseAPI) ProblemStatistics(ctx context.Context, problem *kilonova.Problem, lookingUser *UserBrief) (*ProblemStatistics, *StatusError)

func (*BaseAPI) ProblemTags

func (s *BaseAPI) ProblemTags(ctx context.Context, problemID int) ([]*kilonova.Tag, *StatusError)

func (*BaseAPI) ProblemViewers

func (s *BaseAPI) ProblemViewers(ctx context.Context, pbid int) ([]*kilonova.UserBrief, *StatusError)

func (*BaseAPI) Problems

func (s *BaseAPI) Problems(ctx context.Context, filter kilonova.ProblemFilter) ([]*kilonova.Problem, *StatusError)

When editing Problems, please edit ScoredProblems as well

func (*BaseAPI) PurgeTestData

func (s *BaseAPI) PurgeTestData(testID int) error

func (*BaseAPI) RawSubmission

func (s *BaseAPI) RawSubmission(ctx context.Context, id int) (*kilonova.Submission, *StatusError)

Remember to do proper authorization when using this

func (*BaseAPI) RawSubmissions

func (s *BaseAPI) RawSubmissions(ctx context.Context, filter kilonova.SubmissionFilter) ([]*kilonova.Submission, *StatusError)

Should only ever be used for grader stuff

func (*BaseAPI) RegisterContestUser

func (s *BaseAPI) RegisterContestUser(ctx context.Context, contest *kilonova.Contest, userID int) *StatusError

func (*BaseAPI) RegisterGrader

func (s *BaseAPI) RegisterGrader(gr interface{ Wake() })

func (*BaseAPI) RelevantTags

func (s *BaseAPI) RelevantTags(ctx context.Context, tagID int, max int) ([]*kilonova.Tag, *StatusError)

func (*BaseAPI) RemainingSubmissionCount

func (s *BaseAPI) RemainingSubmissionCount(ctx context.Context, contest *kilonova.Contest, problem *kilonova.Problem, user *kilonova.UserBrief) (int, *StatusError)

func (*BaseAPI) RemoveSession

func (s *BaseAPI) RemoveSession(ctx context.Context, sid string) *StatusError

func (*BaseAPI) RenderMarkdown

func (s *BaseAPI) RenderMarkdown(src []byte, ctx *kilonova.RenderContext) ([]byte, *StatusError)

func (*BaseAPI) RenderedBlogPostDesc

func (s *BaseAPI) RenderedBlogPostDesc(ctx context.Context, post *kilonova.BlogPost, lang string, format string) ([]byte, *StatusError)

func (*BaseAPI) RenderedProblemDesc

func (s *BaseAPI) RenderedProblemDesc(ctx context.Context, problem *kilonova.Problem, lang string, format string) ([]byte, *StatusError)

func (*BaseAPI) ResetProblemSubmissions

func (s *BaseAPI) ResetProblemSubmissions(ctx context.Context, problem *kilonova.Problem) *StatusError

func (*BaseAPI) ResetSubmission

func (s *BaseAPI) ResetSubmission(ctx context.Context, id int) *StatusError

func (*BaseAPI) ResetWaitingSubmissions

func (s *BaseAPI) ResetWaitingSubmissions(ctx context.Context) *StatusError

func (*BaseAPI) SaveAttachmentRender

func (s *BaseAPI) SaveAttachmentRender(attID int, data []byte) error

func (*BaseAPI) SaveTestInput

func (s *BaseAPI) SaveTestInput(testID int, input io.Reader) error

func (*BaseAPI) SaveTestOutput

func (s *BaseAPI) SaveTestOutput(testID int, output io.Reader) error

func (*BaseAPI) ScoredProblem

func (s *BaseAPI) ScoredProblem(ctx context.Context, problemID int, userID int) (*kilonova.ScoredProblem, *StatusError)

func (*BaseAPI) ScoredProblems

func (s *BaseAPI) ScoredProblems(ctx context.Context, filter kilonova.ProblemFilter, user *kilonova.UserBrief) ([]*kilonova.ScoredProblem, *StatusError)

func (*BaseAPI) SearchProblems

func (s *BaseAPI) SearchProblems(ctx context.Context, filter kilonova.ProblemFilter, user *kilonova.UserBrief) ([]*FullProblem, int, *StatusError)

SearchProblems is like the functions above but returns more detailed results for problems

func (*BaseAPI) SendPasswordResetEmail

func (s *BaseAPI) SendPasswordResetEmail(ctx context.Context, userID int, name, email string) *StatusError

SendPasswordResetEmail sends a password reset email to the user. Please provide a good context.

func (*BaseAPI) SendVerificationEmail

func (s *BaseAPI) SendVerificationEmail(ctx context.Context, userID int, name, email string) *StatusError

SendVerificationEmail updates the user metadata with an unverified email status and sends an email with the hard-coded template to the desired user. Please provide a good context.

NOTE: I think the user update breaks some single responsibility principle or something, but I think most places this could be used also does this, so meh.

If `email` is different than the user's email, the email address is also updated.

func (*BaseAPI) SessionUser

func (s *BaseAPI) SessionUser(ctx context.Context, sid string) (*kilonova.UserFull, *StatusError)

func (*BaseAPI) SetAdmin

func (s *BaseAPI) SetAdmin(ctx context.Context, userID int, toSet bool) *StatusError

func (*BaseAPI) SetForceUsernameChange

func (s *BaseAPI) SetForceUsernameChange(ctx context.Context, userID int, force bool) *StatusError

func (*BaseAPI) SetProposer

func (s *BaseAPI) SetProposer(ctx context.Context, userID int, toSet bool) *StatusError

func (*BaseAPI) SetUserLockout

func (s *BaseAPI) SetUserLockout(ctx context.Context, userID int, lockout bool) *StatusError

func (*BaseAPI) Signup

func (s *BaseAPI) Signup(ctx context.Context, email, uname, pwd, lang string, theme kilonova.PreferredTheme) (int, *StatusError)

func (*BaseAPI) SolvedProblems

func (s *BaseAPI) SolvedProblems(ctx context.Context, user *kilonova.UserBrief, lookingUser *kilonova.UserBrief) ([]*kilonova.ScoredProblem, *StatusError)

Deprecated. TODO: Remove

func (*BaseAPI) Start

func (s *BaseAPI) Start(ctx context.Context) *StatusError

func (*BaseAPI) StartContestRegistration

func (s *BaseAPI) StartContestRegistration(ctx context.Context, contest *kilonova.Contest, userID int) *StatusError

func (*BaseAPI) StripContestAccess

func (s *BaseAPI) StripContestAccess(ctx context.Context, pbid int, uid int) *StatusError

func (*BaseAPI) StripProblemAccess

func (s *BaseAPI) StripProblemAccess(ctx context.Context, pbid int, uid int) *StatusError

func (*BaseAPI) SubTask

func (s *BaseAPI) SubTask(ctx context.Context, problemID int, subtaskVID int) (*kilonova.SubTask, *StatusError)

func (*BaseAPI) SubTasks

func (s *BaseAPI) SubTasks(ctx context.Context, problemID int) ([]*kilonova.SubTask, *StatusError)

func (*BaseAPI) SubTasksByTest

func (s *BaseAPI) SubTasksByTest(ctx context.Context, problemID, testID int) ([]*kilonova.SubTask, *StatusError)

func (*BaseAPI) SubTest

func (s *BaseAPI) SubTest(ctx context.Context, id int) (*kilonova.SubTest, *StatusError)

func (*BaseAPI) SubTests

func (s *BaseAPI) SubTests(ctx context.Context, submissionID int) ([]*kilonova.SubTest, *StatusError)

func (*BaseAPI) Submission

func (s *BaseAPI) Submission(ctx context.Context, subid int, lookingUser *UserBrief) (*FullSubmission, *StatusError)

func (*BaseAPI) SubmissionPaste

func (s *BaseAPI) SubmissionPaste(ctx context.Context, id string) (*kilonova.SubmissionPaste, *StatusError)

func (*BaseAPI) SubmissionSubTasks

func (s *BaseAPI) SubmissionSubTasks(ctx context.Context, subID int) ([]*kilonova.SubmissionSubTask, *StatusError)

func (*BaseAPI) Submissions

func (s *BaseAPI) Submissions(ctx context.Context, filter kilonova.SubmissionFilter, look bool, lookingUser *UserBrief) (*Submissions, *StatusError)

func (*BaseAPI) SubtestReader

func (s *BaseAPI) SubtestReader(subtest int) (io.ReadSeekCloser, error)

func (*BaseAPI) SubtestWriter

func (s *BaseAPI) SubtestWriter(subtest int) (io.WriteCloser, error)

func (*BaseAPI) TagByID

func (s *BaseAPI) TagByID(ctx context.Context, id int) (*kilonova.Tag, *StatusError)

func (*BaseAPI) TagByLooseName

func (s *BaseAPI) TagByLooseName(ctx context.Context, name string) (*kilonova.Tag, *StatusError)

func (*BaseAPI) TagByName

func (s *BaseAPI) TagByName(ctx context.Context, name string) (*kilonova.Tag, *StatusError)

func (*BaseAPI) Tags

func (s *BaseAPI) Tags(ctx context.Context) ([]*kilonova.Tag, *StatusError)

func (*BaseAPI) TagsByID

func (s *BaseAPI) TagsByID(ctx context.Context, tagIDs []int) ([]*kilonova.Tag, *StatusError)

func (*BaseAPI) TagsByType

func (s *BaseAPI) TagsByType(ctx context.Context, tagType kilonova.TagType) ([]*kilonova.Tag, *StatusError)

func (*BaseAPI) Test

func (s *BaseAPI) Test(ctx context.Context, pbID int, testVID int) (*kilonova.Test, *StatusError)

func (*BaseAPI) TestInput

func (s *BaseAPI) TestInput(testID int) (io.ReadSeekCloser, error)

func (*BaseAPI) TestOutput

func (s *BaseAPI) TestOutput(testID int) (io.ReadSeekCloser, error)

func (*BaseAPI) Tests

func (s *BaseAPI) Tests(ctx context.Context, pbID int) ([]*kilonova.Test, *StatusError)

func (*BaseAPI) ToggleDeepPbListProblems

func (s *BaseAPI) ToggleDeepPbListProblems(ctx context.Context, list *kilonova.ProblemList, deep bool, visible bool) *kilonova.StatusError

func (*BaseAPI) UpdateAttachment

func (s *BaseAPI) UpdateAttachment(ctx context.Context, aid int, upd *kilonova.AttachmentUpdate) *StatusError

func (*BaseAPI) UpdateAttachmentData

func (s *BaseAPI) UpdateAttachmentData(ctx context.Context, aid int, data []byte, author *kilonova.UserBrief) *StatusError

func (*BaseAPI) UpdateBlogPost

func (s *BaseAPI) UpdateBlogPost(ctx context.Context, id int, upd kilonova.BlogPostUpdate) *StatusError

func (*BaseAPI) UpdateConfig

func (s *BaseAPI) UpdateConfig(ctx context.Context, upd ConfigUpdate) *StatusError

func (*BaseAPI) UpdateContest

func (s *BaseAPI) UpdateContest(ctx context.Context, id int, upd kilonova.ContestUpdate) *kilonova.StatusError

func (*BaseAPI) UpdateContestAnnouncement

func (s *BaseAPI) UpdateContestAnnouncement(ctx context.Context, announcementID int, text string) *StatusError

func (*BaseAPI) UpdateContestProblems

func (s *BaseAPI) UpdateContestProblems(ctx context.Context, id int, list []int) *StatusError

func (*BaseAPI) UpdateProblem

func (s *BaseAPI) UpdateProblem(ctx context.Context, id int, args kilonova.ProblemUpdate, updater *kilonova.UserBrief) *StatusError

`updater` is an optional parameter, specifying the author of the change. It handles the visibility change option. Visibility is the only parameter that can not be updated by a mere problem editor, it requires admin permissions! Please note that, if updater is not specified, the function won't attempt to ensure correct permissions for visibility.

func (*BaseAPI) UpdateProblemList

func (s *BaseAPI) UpdateProblemList(ctx context.Context, id int, upd kilonova.ProblemListUpdate) *StatusError

func (*BaseAPI) UpdateProblemListProblems

func (s *BaseAPI) UpdateProblemListProblems(ctx context.Context, id int, list []int) *StatusError

func (*BaseAPI) UpdateProblemListSublists

func (s *BaseAPI) UpdateProblemListSublists(ctx context.Context, id int, listIDs []int) *StatusError

func (*BaseAPI) UpdateProblemTags

func (s *BaseAPI) UpdateProblemTags(ctx context.Context, problemID int, tagIDs []int) *StatusError

func (*BaseAPI) UpdateSubTask

func (s *BaseAPI) UpdateSubTask(ctx context.Context, id int, upd kilonova.SubTaskUpdate) *StatusError

func (*BaseAPI) UpdateSubTaskTests

func (s *BaseAPI) UpdateSubTaskTests(ctx context.Context, id int, testIDs []int) *StatusError

func (*BaseAPI) UpdateSubTest

func (s *BaseAPI) UpdateSubTest(ctx context.Context, id int, upd kilonova.SubTestUpdate) *StatusError

func (*BaseAPI) UpdateSubmission

func (s *BaseAPI) UpdateSubmission(ctx context.Context, id int, status kilonova.SubmissionUpdate) *StatusError

func (*BaseAPI) UpdateSubmissionSubtaskPercentage

func (s *BaseAPI) UpdateSubmissionSubtaskPercentage(ctx context.Context, id int, percentage decimal.Decimal) *kilonova.StatusError

func (*BaseAPI) UpdateTagName

func (s *BaseAPI) UpdateTagName(ctx context.Context, tag *kilonova.Tag, newName string) *StatusError

func (*BaseAPI) UpdateTagType

func (s *BaseAPI) UpdateTagType(ctx context.Context, tag *kilonova.Tag, newType kilonova.TagType) *StatusError

func (*BaseAPI) UpdateTest

func (s *BaseAPI) UpdateTest(ctx context.Context, testID int, upd kilonova.TestUpdate) *StatusError

func (*BaseAPI) UpdateUser

func (s *BaseAPI) UpdateUser(ctx context.Context, userID int, upd kilonova.UserUpdate) *StatusError

func (*BaseAPI) UpdateUserPassword

func (s *BaseAPI) UpdateUserPassword(ctx context.Context, uid int, password string) *StatusError

func (*BaseAPI) UpdateUsername

func (s *BaseAPI) UpdateUsername(ctx context.Context, userID int, newName string, checkUsed bool, fromAdmin bool) *StatusError

fromAdmin also should include the forced username changes

func (*BaseAPI) UserBlogPosts

func (s *BaseAPI) UserBlogPosts(ctx context.Context, userID int, lookingUser *kilonova.UserBrief) ([]*kilonova.BlogPost, *StatusError)

func (*BaseAPI) UserBrief

func (s *BaseAPI) UserBrief(ctx context.Context, id int) (*UserBrief, *StatusError)

func (*BaseAPI) UserBriefByName

func (s *BaseAPI) UserBriefByName(ctx context.Context, name string) (*UserBrief, *StatusError)

func (*BaseAPI) UserContestFreezeTime

func (s *BaseAPI) UserContestFreezeTime(user *kilonova.UserBrief, contest *kilonova.Contest, showFrozen bool) *time.Time

The leaderboards are not frozen if:

  • No freeze time is set
  • Current moment is before freeze time
  • User is contest editor

Otherwise, leaderboard should be frozen Also, in case the editor wants to see the frozen leaderboard, an option is provided

func (*BaseAPI) UserFull

func (s *BaseAPI) UserFull(ctx context.Context, id int) (*UserFull, *StatusError)

func (*BaseAPI) UserFullByEmail

func (s *BaseAPI) UserFullByEmail(ctx context.Context, email string) (*UserFull, *StatusError)

func (*BaseAPI) UserFullByName

func (s *BaseAPI) UserFullByName(ctx context.Context, name string) (*UserFull, *StatusError)

func (*BaseAPI) UsernameChangeHistory

func (s *BaseAPI) UsernameChangeHistory(ctx context.Context, userID int) ([]*kilonova.UsernameChange, *StatusError)

func (*BaseAPI) UsersBrief

func (s *BaseAPI) UsersBrief(ctx context.Context, filter kilonova.UserFilter) ([]*UserBrief, *StatusError)

func (*BaseAPI) VerifyUserPassword

func (s *BaseAPI) VerifyUserPassword(ctx context.Context, uid int, password string) *StatusError

func (*BaseAPI) VisibleContests

func (s *BaseAPI) VisibleContests(ctx context.Context, user *kilonova.UserBrief) ([]*kilonova.Contest, *StatusError)

func (*BaseAPI) VisibleFutureContests

func (s *BaseAPI) VisibleFutureContests(ctx context.Context, user *kilonova.UserBrief) ([]*kilonova.Contest, *StatusError)

func (*BaseAPI) VisibleRunningContests

func (s *BaseAPI) VisibleRunningContests(ctx context.Context, user *kilonova.UserBrief) ([]*kilonova.Contest, *StatusError)

func (*BaseAPI) WakeGrader

func (s *BaseAPI) WakeGrader()

type ConfigUpdate

type ConfigUpdate struct {
	DefaultLanguage *string `json:"default_lang"`

	TestMaxMem   *int   `json:"test_max_mem"`
	GlobalMaxMem *int64 `json:"global_max_mem"`
	NumWorkers   *int   `json:"num_workers"`

	BannedHotProblems []int `json:"banned_hot_pbs"`
}

type FullProblem

type FullProblem struct {
	kilonova.ScoredProblem
	Tags []*kilonova.Tag `json:"tags"`

	SolvedBy    int `json:"solved_by"`
	AttemptedBy int `json:"attempted_by"`
}

type FullProblemList

type FullProblemList struct {
	kilonova.ProblemList
	Problems []*kilonova.ScoredProblem `json:"problems"`
	SubLists []*FullProblemList        `json:"problem_lists"`

	SolvedCount int  `json:"solved_count"`
	DepthLevel  int  `json:"depth_level"`
	Root        bool `json:"root"`
}

type FullSubmission

type FullSubmission = kilonova.FullSubmission

type ProblemStatistics

type ProblemStatistics struct {
	NumSolved    int `json:"num_solved"`
	NumAttempted int `json:"num_attempted"`

	SizeLeaderboard   *Submissions `json:"size_leaderboard"`
	MemoryLeaderboard *Submissions `json:"memory_leaderboard"`
	TimeLeaderboard   *Submissions `json:"time_leaderboard"`
}

type StatusError

type StatusError = kilonova.StatusError

func Statusf

func Statusf(status int, format string, args ...any) *StatusError

func WrapError

func WrapError(err error, text string) *StatusError

type Submissions

type Submissions struct {
	Submissions []*kilonova.Submission    `json:"submissions"`
	Count       int                       `json:"count"`
	Users       map[int]*UserBrief        `json:"users"`
	Problems    map[int]*kilonova.Problem `json:"problems"`
}

type UserBrief

type UserBrief = kilonova.UserBrief

type UserFull

type UserFull = kilonova.UserFull

Directories

Path Synopsis
knkatex
Code in katex.go has been mostly derived from [goldmark-mathjax](https://github.com/litao91/goldmark-mathjax).
Code in katex.go has been mostly derived from [goldmark-mathjax](https://github.com/litao91/goldmark-mathjax).

Jump to

Keyboard shortcuts

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