events

package
v0.0.0-...-b84af7b Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	POSTS_NEW       = "posts:new"
	POSTS_COMMENT   = "posts:comment"
	POST_VIEW       = "posts:view"
	POSTS_REACHED   = "posts:reached"
	POST_DELETED    = "posts:deleted"
	RECENT_ACTIVITY = "activity:recent"

	COMMENT_DELETE          = "comments:delete"
	COMMENT_UPDATE          = "comments:update"
	COMMENT_UPVOTE          = "comments:upvote"
	COMMENT_VOTE            = "comments:vote"
	VOTE                    = "vote"
	COMMENT_UPVOTE_REMOVE   = "comments:upvote.remove"
	COMMENT_DOWNVOTE        = "comments:downvote"
	COMMENT_DOWNVOTE_REMOVE = "comments:downvote.remove"

	NEW_FLAG    = "flag:new"
	NEW_BAN     = "flag:ban"
	NEW_MENTION = "new:mentions"

	RAW_EMIT = "transmit:emit"
)

Variables

View Source
var (

	// In -put channel for incoming events.
	In chan Event

	// On "event" channel. Register event handlers using channels.
	On chan EventHandler
)
View Source
var Handlers map[string][]Handler

Map of handlers that will react to events.

Functions

func Boot

func Boot()

Types

type Event

type Event struct {
	Name   string
	Sign   *UserSign
	Params map[string]interface{}
}

func DeleteComment

func DeleteComment(sign UserSign, postId, id bson.ObjectId) Event

func DeletePost

func DeletePost(sign UserSign, id bson.ObjectId) Event

func NewBanFlag

func NewBanFlag(userID bson.ObjectId) Event

func NewFlag

func NewFlag(id bson.ObjectId) Event

func PostComment

func PostComment(id bson.ObjectId) Event

func PostNew

func PostNew(id bson.ObjectId) Event

func PostView

func PostView(sign UserSign, id bson.ObjectId) Event

func PostsReached

func PostsReached(sign UserSign, list []bson.ObjectId) Event

func RawEmit

func RawEmit(channel, event string, params map[string]interface{}) Event

func TrackActivity

func TrackActivity(m model.Activity) Event

func TrackMention

func TrackMention(userID, relatedID bson.ObjectId, related string, usersID []bson.ObjectId) Event

func UpdateComment

func UpdateComment(sign UserSign, postId, id bson.ObjectId) Event

func Vote

func Vote(vote votes.Vote) Event

type EventHandler

type EventHandler struct {
	On      string
	Handler Handler
}

type Handler

type Handler func(Event) error

type UserSign

type UserSign struct {
	Reason string
	UserID bson.ObjectId
}

Jump to

Keyboard shortcuts

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