reactions

package module
v0.0.0-...-c08ef9d Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 2 Imported by: 21

README

reactions

Go Reference

Package reactions provides a reactions service definition.

Installation

go get github.com/shurcooL/reactions

Directories

Path Synopsis
component Package component contains individual components that can render themselves as HTML.
emojis Package emojis contains emojis image data.
fs Package fs implements reactions.Service using a virtual filesystem.
mousemoveclick mousemoveclick is a script to demonstrate a peculiar browser behavior on iOS.

License

Documentation

Overview

Package reactions provides a reactions service definition.

Index

Constants

This section is empty.

Variables

View Source
var Sorted = []string{}/* 1292 elements not displayed */

Sorted is a sorted list of reactions.

Functions

func Position

func Position(emojiID string) string

Position returns position of emojiID within the emojis tilemap.

Types

type EmojiID

type EmojiID string

EmojiID is the id of a reaction. For example, "+1". TODO, THINK: Maybe keep the colons, i.e., ":+1:".

type Reaction

type Reaction struct {
	Reaction EmojiID
	Users    []users.User // Length is 1 or more. First entry is first person who reacted.
}

Reaction represents a single reaction, backed by 1 or more users.

type Service

type Service interface {
	// List all reactions at uri. Map key is reactable ID.
	// uri is clean '/'-separated URI. E.g., "example.com/page".
	// If uri isn't a valid reactable URI, a not exist error is returned.
	List(ctx context.Context, uri string) (map[string][]Reaction, error)

	// Get reactions for id at uri.
	// uri is clean '/'-separated URI. E.g., "example.com/page".
	// If uri/id doesn't point at a valid reactable target,
	// a not exist error is returned.
	Get(ctx context.Context, uri string, id string) ([]Reaction, error)

	// Toggle a reaction for id at uri.
	// If uri/id doesn't point at a valid reactable target,
	// a not exist error is returned.
	Toggle(ctx context.Context, uri string, id string, tr ToggleRequest) ([]Reaction, error)
}

Service defines methods of a reactions service.

type ToggleRequest

type ToggleRequest struct {
	Reaction EmojiID
}

ToggleRequest is a request to toggle a reaction.

func (ToggleRequest) Validate

func (ToggleRequest) Validate() error

Validate returns non-nil error if the request is invalid.

Directories

Path Synopsis
Package component contains individual components that can render themselves as HTML.
Package component contains individual components that can render themselves as HTML.
Package emojis contains emojis image data.
Package emojis contains emojis image data.
Package fs implements reactions.Service using a virtual filesystem.
Package fs implements reactions.Service using a virtual filesystem.
mousemoveclick is a script to demonstrate a peculiar browser behavior on iOS.
mousemoveclick is a script to demonstrate a peculiar browser behavior on iOS.

Jump to

Keyboard shortcuts

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