handler

package
v0.0.0-...-3da28a4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MailRegexp = regexp.MustCompile(
	`[\w\-\._]+@[\w\-\._]+\.[A-Za-z]+`,
)
View Source
var UrlRegexp = regexp.MustCompile(
	`https?://[\w/:%#\$&\?\(\)~\.=\+\-]+`,
)

Functions

func CheckAdminRole

func CheckAdminRole(rolesStr string) error

Check exists `admin` role in CateiruSSO received claims.

func CreateUser

func CreateUser(ctx context.Context, base *base.Base, claims *sso.Claims) (*ent.User, error)

Create New User from SSO Claims

func GetClaims

func GetClaims(code string) (*sso.Claims, error)

Get Claims from sso code via CateiruSSO

func GetFavicon

func GetFavicon(siteUrl string) (string, error)

Search favicon

- HTML parse

  • get `link[rel=icon]` elements

- GET `/favicon.ico`

  • if not found in HTML

func GetUserAgent

func GetUserAgent(e echo.Context) (*sender.UserData, error)

Get user data from User-Agent or Client Hints

If useable Client Hints, use it. Other, used User-Agent.

func SwitchPostingService

func SwitchPostingService(ctx context.Context, db *db.DB, u *ent.User, forms *sender.SendForm) error

func UpdateUser

func UpdateUser(ctx context.Context, base *base.Base, claims *sso.Claims) (*ent.User, error)

func ValidateMail

func ValidateMail(target string) error

func ValidateURL

func ValidateURL(target string) error

Types

type BioResponse

type BioResponse struct {
	Biography *ent.Biography `json:"biography"`
	Location  *ent.Location  `json:"location"`
}

type Handler

type Handler struct {
	*base.Base
}

func NewHandler

func NewHandler(db *db.DB) (*Handler, error)

func (*Handler) AllUsersHandler

func (h *Handler) AllUsersHandler(e echo.Context) error

Response all users in users db

func (*Handler) BioHandler

func (h *Handler) BioHandler(e echo.Context) error

Get my bio

func (*Handler) CategoryHandler

func (h *Handler) CategoryHandler(e echo.Context) error

Response all categories

func (*Handler) ChangeSelect

func (h *Handler) ChangeSelect(e echo.Context) error

func (*Handler) ContactDefaultHandler

func (h *Handler) ContactDefaultHandler(c echo.Context) error

func (*Handler) ContactDeleteHandler

func (h *Handler) ContactDeleteHandler(e echo.Context) error

func (*Handler) ContactGetHandler

func (h *Handler) ContactGetHandler(e echo.Context) error

func (*Handler) ContactHandler

func (h *Handler) ContactHandler(e echo.Context) error

Contact form API

func (*Handler) ContactPreviewUserDataHandler

func (h *Handler) ContactPreviewUserDataHandler(e echo.Context) error

Preview UserData from User-Agent or UA-CH

func (*Handler) CreateBioHandler

func (h *Handler) CreateBioHandler(e echo.Context) error

Set a new bio

require form is - is_public: boolean - location_id: uint32 - position: string - position_ja: string - join_date: type date - leave_date: Optional RFC3339 type date

func (*Handler) CreateCategoryHandler

func (h *Handler) CreateCategoryHandler(e echo.Context) error

- name: string - name_ja: string - emoji: len 1 string

func (*Handler) CreateContactDefaultHandler

func (h *Handler) CreateContactDefaultHandler(c echo.Context) error

func (*Handler) CreateLinkHandler

func (h *Handler) CreateLinkHandler(e echo.Context) error

Create a new Link

Require form data - name - name_ja - site_url - category_id

func (*Handler) CreateLocationHandler

func (h *Handler) CreateLocationHandler(e echo.Context) error

create a new location

- type: `univ` or `corp` - name: string - name_ja: string - address: string - address_ja: string

func (*Handler) CreateProductHandler

func (h *Handler) CreateProductHandler(e echo.Context) error

Create a new product

form values: - name: string - name_ja: string - detail: string - detail_ja: string - site_url: string - github_url: Optional string - dev_time: RFC3339type date - thumbnail: Optional string

func (*Handler) DeleteBioHandler

func (h *Handler) DeleteBioHandler(e echo.Context) error

func (*Handler) DeleteCategoryHandler

func (h *Handler) DeleteCategoryHandler(e echo.Context) error

func (*Handler) DeleteContactDefaultHandler

func (h *Handler) DeleteContactDefaultHandler(c echo.Context) error

func (*Handler) DeleteLinkHandler

func (h *Handler) DeleteLinkHandler(e echo.Context) error

func (*Handler) DeleteLocationHandler

func (h *Handler) DeleteLocationHandler(e echo.Context) error

func (*Handler) DeleteProductHandler

func (h *Handler) DeleteProductHandler(e echo.Context) error

func (*Handler) LinkHandler

func (h *Handler) LinkHandler(e echo.Context) error

Response all Links

func (*Handler) LocationHandler

func (h *Handler) LocationHandler(e echo.Context) error

func (*Handler) LoginHandler

func (h *Handler) LoginHandler(c echo.Context) error

Login from OIDC Require `?code=` param. - code param is Open ID Connect code.

func (*Handler) LoginURLHandler

func (h *Handler) LoginURLHandler(c echo.Context) error

Redirect to CateiruSSO Login page.

func (*Handler) LogoutHandler

func (h *Handler) LogoutHandler(e echo.Context) error

Logout session no delete users.

func (*Handler) MeHandler

func (h *Handler) MeHandler(e echo.Context) error

Response login user data

func (*Handler) NoticeHandler

func (h *Handler) NoticeHandler(e echo.Context) error

func (*Handler) ProductHandler

func (h *Handler) ProductHandler(e echo.Context) error

Response to all products of me.

func (*Handler) PublicContactDefaultHandler

func (h *Handler) PublicContactDefaultHandler(c echo.Context) error

func (*Handler) PublicProductsHandler

func (h *Handler) PublicProductsHandler(e echo.Context) error

func (*Handler) PublicProfileHandler

func (h *Handler) PublicProfileHandler(e echo.Context) error

Response public profiles

func (*Handler) RootHandler

func (h *Handler) RootHandler(c echo.Context) error

func (*Handler) UpdateBioHandler

func (h *Handler) UpdateBioHandler(e echo.Context) error

Set a new bio

changeable form is - is_public: boolean - location_id: uint32 - position: string - position_ja: string - join_date: RFC3339 type date - leave_date: RFC3339 type date

func (*Handler) UpdateCategoryHandler

func (h *Handler) UpdateCategoryHandler(e echo.Context) error

- name: string - name_ja: string - emoji: len 1 string

func (*Handler) UpdateContactDefaultHandler

func (h *Handler) UpdateContactDefaultHandler(c echo.Context) error

func (*Handler) UpdateLinkHandler

func (h *Handler) UpdateLinkHandler(e echo.Context) error

func (*Handler) UpdateLocationHandler

func (h *Handler) UpdateLocationHandler(e echo.Context) error

Update location

- type: `univ` or `corp` - name: string - name_ja: string - address: string - address_ja: string

func (*Handler) UpdateNoticeHandler

func (h *Handler) UpdateNoticeHandler(e echo.Context) error

func (*Handler) UpdateProductHandler

func (h *Handler) UpdateProductHandler(e echo.Context) error

Update a product

changeable form values: - name: string - name_ja: string - detail: string - detail_ja: string - site_url: string - github_url: string - dev_time: RFC3339type date - thumbnail: string

func (*Handler) UpdateUserHandler

func (h *Handler) UpdateUserHandler(e echo.Context) error

Update user profiles

changeable profiles - family_name - given_name - family_name_ja - given_name_ja - birth_date - location - location_ja

type LinkResponse

type LinkResponse struct {
	Link     ent.Link     `json:"link"`
	Category ent.Category `json:"category"`
}

type Public

type Public struct {
	// User data
	GivenName    string    `json:"given_name,omitempty"`
	FamilyName   string    `json:"family_name,omitempty"`
	GivenNameJa  string    `json:"given_name_ja,omitempty"`
	FamilyNameJa string    `json:"family_name_ja,omitempty"`
	UserID       string    `json:"user_id,omitempty"`
	BirthDate    time.Time `json:"birth_date,omitempty"`
	Location     string    `json:"location,omitempty"`
	LocationJa   string    `json:"location_ja,omitempty"`
	AvatarURL    string    `json:"avatar_url,omitempty"`
	Created      time.Time `json:"created,omitempty"`
	Modified     time.Time `json:"modified,omitempty"`

	Biographies []PublicBioGraphy    `json:"biographies"`
	Products    []PublicShortProduct `json:"products"`
	Links       []PublicLinkCategory `json:"links"`
}

type PublicBioGraphy

type PublicBioGraphy struct {
	Position   string    `json:"position,omitempty"`
	PositionJa string    `json:"position_ja,omitempty"`
	Join       time.Time `json:"join,omitempty"`
	Leave      time.Time `json:"leave,omitempty"`

	PublicLocation
}
type PublicLink struct {
	Name       string `json:"name,omitempty"`
	NameJa     string `json:"name_ja,omitempty"`
	SiteURL    string `json:"site_url,omitempty"`
	FaviconURL string `json:"favicon_url,omitempty"`
}

type PublicLinkCategory

type PublicLinkCategory struct {
	CategoryId     uint32 `json:"category_id"`
	CategoryName   string `json:"category_name,omitempty"`
	CategoryNameJa string `json:"category_name_ja,omitempty"`
	Emoji          string `json:"emoji,omitempty"`

	Links []PublicLink `json:"links"`
}

type PublicLocation

type PublicLocation struct {
	Type      location.Type `json:"type,omitempty"`
	Name      string        `json:"name,omitempty"`
	NameJa    string        `json:"name_ja,omitempty"`
	Address   string        `json:"address,omitempty"`
	AddressJa string        `json:"address_ja,omitempty"`
}

type PublicProduct

type PublicProduct struct {
	ID        uint32    `json:"id,omitempty"`
	Name      string    `json:"name,omitempty"`
	NameJa    string    `json:"name_ja,omitempty"`
	Detail    string    `json:"detail,omitempty"`
	DetailJa  string    `json:"detail_ja,omitempty"`
	SiteURL   string    `json:"site_url,omitempty"`
	GithubURL string    `json:"github_url,omitempty"`
	DevTime   time.Time `json:"dev_time,omitempty"`
	Thumbnail string    `json:"thumbnail,omitempty"`
}

type PublicShortProduct

type PublicShortProduct struct {
	ID        uint32    `json:"id,omitempty"`
	Name      string    `json:"name,omitempty"`
	NameJa    string    `json:"name_ja,omitempty"`
	Detail    string    `json:"detail,omitempty"`
	DetailJa  string    `json:"detail_ja,omitempty"`
	DevTime   time.Time `json:"dev_time,omitempty"`
	Thumbnail string    `json:"thumbnail,omitempty"`
	GithubURL string    `json:"github_url,omitempty"`
	SiteURL   string    `json:"site_url"`
}

Jump to

Keyboard shortcuts

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