1/*
2 * Copyright © 2018-2020 A Bunch Tell LLC.
3 *
4 * This file is part of WriteFreely.
5 *
6 * WriteFreely is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License, included
8 * in the LICENSE file in this source code package.
9 */
10
11package writefreely
12
13import (
14	"net/http"
15
16	"github.com/writeas/impart"
17)
18
19// Commonly returned HTTP errors
20var (
21	ErrBadFormData    = impart.HTTPError{http.StatusBadRequest, "Expected valid form data."}
22	ErrBadJSON        = impart.HTTPError{http.StatusBadRequest, "Expected valid JSON object."}
23	ErrBadJSONArray   = impart.HTTPError{http.StatusBadRequest, "Expected valid JSON array."}
24	ErrBadAccessToken = impart.HTTPError{http.StatusUnauthorized, "Invalid access token."}
25	ErrNoAccessToken  = impart.HTTPError{http.StatusBadRequest, "Authorization token required."}
26	ErrNotLoggedIn    = impart.HTTPError{http.StatusUnauthorized, "Not logged in."}
27
28	ErrForbiddenCollection        = impart.HTTPError{http.StatusForbidden, "You don't have permission to add to this collection."}
29	ErrForbiddenEditPost          = impart.HTTPError{http.StatusForbidden, "You don't have permission to update this post."}
30	ErrUnauthorizedEditPost       = impart.HTTPError{http.StatusUnauthorized, "Invalid editing credentials."}
31	ErrUnauthorizedGeneral        = impart.HTTPError{http.StatusUnauthorized, "You don't have permission to do that."}
32	ErrBadRequestedType           = impart.HTTPError{http.StatusNotAcceptable, "Bad requested Content-Type."}
33	ErrCollectionUnauthorizedRead = impart.HTTPError{http.StatusUnauthorized, "You don't have permission to access this collection."}
34
35	ErrNoPublishableContent = impart.HTTPError{http.StatusBadRequest, "Supply something to publish."}
36
37	ErrInternalGeneral       = impart.HTTPError{http.StatusInternalServerError, "The humans messed something up. They've been notified."}
38	ErrInternalCookieSession = impart.HTTPError{http.StatusInternalServerError, "Could not get cookie session."}
39
40	ErrUnavailable = impart.HTTPError{http.StatusServiceUnavailable, "Service temporarily unavailable due to high load."}
41
42	ErrCollectionNotFound     = impart.HTTPError{http.StatusNotFound, "Collection doesn't exist."}
43	ErrCollectionGone         = impart.HTTPError{http.StatusGone, "This blog was unpublished."}
44	ErrCollectionPageNotFound = impart.HTTPError{http.StatusNotFound, "Collection page doesn't exist."}
45	ErrPostNotFound           = impart.HTTPError{Status: http.StatusNotFound, Message: "Post not found."}
46	ErrPostBanned             = impart.HTTPError{Status: http.StatusGone, Message: "Post removed."}
47	ErrPostUnpublished        = impart.HTTPError{Status: http.StatusGone, Message: "Post unpublished by author."}
48	ErrPostFetchError         = impart.HTTPError{Status: http.StatusInternalServerError, Message: "We encountered an error getting the post. The humans have been alerted."}
49
50	ErrUserNotFound       = impart.HTTPError{http.StatusNotFound, "User doesn't exist."}
51	ErrRemoteUserNotFound = impart.HTTPError{http.StatusNotFound, "Remote user not found."}
52	ErrUserNotFoundEmail  = impart.HTTPError{http.StatusNotFound, "Please enter your username instead of your email address."}
53
54	ErrUserSilenced = impart.HTTPError{http.StatusForbidden, "Account is silenced."}
55
56	ErrDisabledPasswordAuth = impart.HTTPError{http.StatusForbidden, "Password authentication is disabled."}
57)
58
59// Post operation errors
60var (
61	ErrPostNoUpdatableVals = impart.HTTPError{http.StatusBadRequest, "Supply some properties to update."}
62)
63