tat

package module
v5.2.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: BSD-3-Clause Imports: 14 Imported by: 1

README

Build Status GoDoc Go Report Card

Tat Engine

Documentation: https://ovh.github.io/tat/

Hacking

You've developed a new cool feature? Fixed an annoying bug? We'd be happy to hear from you! Make sure to read CONTRIBUTING.md before.

License

This work is under the BSD license, see the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	// DefaultMessageMaxReplies is max number of replies on a message, can be overrided by topic
	DefaultMessageMaxReplies = 30

	// True in url http way -> string
	True = "true"
	// False in url http way -> string
	False = "false"
	// TreeViewNoTree is default value
	TreeViewNoTree = "notree"
	// TreeViewOneTree is onetree value for treeView
	TreeViewOneTree = "onetree"
	// TreeViewFullTree is fulltree value for treeView
	TreeViewFullTree = "fulltree"

	// MessageActionCreate for create a message
	MessageActionCreate = "create"
	// MessageActionUpdate for update action on a message
	MessageActionUpdate = "update"
	// MessageActionReply for "reply action on a message
	MessageActionReply = "reply"
	// MessageActionLike for  "like action on a message
	MessageActionLike = "like"
	// MessageActionUnlike for unlike action on a message
	MessageActionUnlike = "unlike"
	// MessageActionLabel for "label action on a message
	MessageActionLabel = "label"
	// MessageActionUnlabel for nlabel action on a message
	MessageActionUnlabel = "unlabel"
	// MessageActionVoteup for voteup action on a message
	MessageActionVoteup = "voteup"
	// MessageActionVotedown for tedown action on a message
	MessageActionVotedown = "votedown"
	// MessageActionUnvoteup for voteup action on a message
	MessageActionUnvoteup = "unvoteup"
	// MessageActionUnvotedown for tedown action on a message
	MessageActionUnvotedown = "unvotedown"
	// MessageActionRelabel for relabel action on a message
	MessageActionRelabel = "relabel"
	// MessageActionRelabelOrCreate for relabeloradd action on a message
	MessageActionRelabelOrCreate = "relabelorcreate"
	// MessageActionConcat for concat action on a message
	MessageActionConcat = "concat"
	// MessageActionMove for move action on a message
	MessageActionMove = "move"
	// MessageActionTask for task action on a message
	MessageActionTask = "task"
	// MessageActionUntask for untask action on a message
	MessageActionUntask = "untask"
)
View Source
const (
	// TatHeaderUsername is Tat_username header
	TatHeaderUsername = "Tat_username"
	// TatHeaderPassword is Tat_password header
	TatHeaderPassword = "Tat_password"
	// TatHeaderXTatRefererLower contains tat microservice name & version "X-TAT-FROM"
	TatHeaderXTatRefererLower = "X-Tat-Referer"
)

Variables

View Source
var (
	HookTypeWebHook = "tathook-webhook"
	HookTypeKafka   = "tathook-kafka"
	HookTypeXMPP    = "tathook-xmpp"
	HookTypeXMPPOut = "tathook-xmpp-out"
	HookTypeXMPPIn  = "tathook-xmpp-in"
)
View Source
var DebugLogFunc = log.Printf //func(string, ...interface{})

DebugLogFunc is a function that logs the provided message with optional fmt.Sprintf-style arguments. By default, logs to the default log.Logger.

View Source
var ErrClientNotInitiliazed = fmt.Errorf("Client is not initialized")

ErrClientNotInitiliazed is a predifined Error

View Source
var ErrorLogFunc = log.Printf

ErrorLogFunc is a function that logs the provided message with optional fmt.Sprintf-style arguments. By default, logs to the default log.Logger.

View Source
var HTTPClient httpClient

HTTPClient is HTTClient or testHTTPClient for tests

View Source
var HookTat2XMPPHeaderKey = "Tat2xmppkey"
View Source
var IsDebug = false

IsDebug display request / response in ErrorLogFunc if true

View Source
var Version string

Version of Tat

Functions

func ArrayContains

func ArrayContains(array []string, element string) bool

ArrayContains return true if element is in array

func CheckAndFixNameTopic

func CheckAndFixNameTopic(topicName string) (string, error)

CheckAndFixNameTopic Add a / to topic name is it is not present return an error if length of name is < 4 or > 100

func DateFromFloat

func DateFromFloat(in float64) time.Time

DateFromFloat returns a time.Time from a float

func Error

func Error(err error) (int, interface{})

Error returns the error in the proper way

func GetDateRef

func GetDateRef(pattern string) (time.Time, error)

func ItemInBothArrays

func ItemInBothArrays(arrayA, arrayB []string) bool

ItemInBothArrays return true if an element is in both array

func NewError

func NewError(code int, format string, a ...interface{}) error

NewError returns a new APIError

func Round

func Round(f float64) float64

Round rounds float

func SplitFloatForTimeUnix

func SplitFloatForTimeUnix(in float64) (int64, int64)

SplitFloatForTimeUnix returns a.b a and b, b with 9 numbers then, time.Unix(a,b) for initialize date from a float64

func Sprint

func Sprint(v interface{}) ([]byte, error)

Sprint return the value in json as a string

func TSFromDate

func TSFromDate(in time.Time) float64

TSFromDate returns a timestamp with float.

func TSFromNow

func TSFromNow() float64

TSFromNow returns a timestamp with float for timeNow()

Types

type APIError

type APIError struct {
	Code  int    `json:"-"`
	Cause string `json:"error"`
}

APIError is the Error wrapper for api error management

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) String

func (e *APIError) String() string

type Auth

type Auth struct {
	HashedPassword    string `bson:"hashedPassword" json:"-"`
	HashedTokenVerify string `bson:"hashedTokenVerify" json:"-"`
	DateRenewPassword int64  `bson:"dateRenewPassword" json:"dateRenewPassword"`
	DateAskReset      int64  `bson:"dateAskReset" json:"dateAskReset"`
	DateVerify        int64  `bson:"dateVerify" json:"dateVerify"`
	EmailVerified     bool   `bson:"emailVerified" json:"emailVerified"`
}

Auth User Struct

type Author

type Author struct {
	Username string `bson:"username" json:"username"`
	Fullname string `bson:"fullname" json:"fullname"`
}

Author struct

type CacheableCriteria

type CacheableCriteria interface {
	CacheKey() []string
}

CacheableCriteria must return strnig slice describing the redis key

type CapabilitieHook

type CapabilitieHook struct {
	HookType    string `json:"type"`
	HookEnabled bool   `json:"enabled"`
}

type Capabilities

type Capabilities struct {
	UsernameFromEmail bool              `json:"username_from_email"`
	Hooks             []CapabilitieHook `json:"hooks"`
}

type CheckTopicsUserJSON

type CheckTopicsUserJSON struct {
	Username         string `json:"username"  binding:"required"`
	FixPrivateTopics bool   `json:"fixPrivateTopics"  binding:"required"`
	FixDefaultGroup  bool   `json:"fixDefaultGroup"  binding:"required"`
}

CheckTopicsUserJSON used to check if user have default topics

type Client

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

Client represents a Client configuration to connect to api

func NewClient

func NewClient(opts Options) (*Client, error)

NewClient initialize a TAT client

func (*Client) GroupAddAdminUsers

func (c *Client) GroupAddAdminUsers(groupname string, users []string) error

GroupAddAdminUsers adds an admin user on a group

func (*Client) GroupAddUsers

func (c *Client) GroupAddUsers(groupname string, users []string) error

GroupAddUsers adds users on a group

func (*Client) GroupCreate

func (c *Client) GroupCreate(g GroupJSON) (*Group, error)

GroupCreate creates a group

func (*Client) GroupDelete

func (c *Client) GroupDelete(groupname string) error

GroupDelete delete a group

func (*Client) GroupDeleteAdminUsers

func (c *Client) GroupDeleteAdminUsers(groupname string, users []string) error

GroupDeleteAdminUsers removes admin users from a group

func (*Client) GroupDeleteUsers

func (c *Client) GroupDeleteUsers(groupname string, users []string) error

GroupDeleteUsers deletes users from a group

func (*Client) GroupList

func (c *Client) GroupList(criteria *GroupCriteria) (*GroupsJSON, error)

GroupList returns groups

func (*Client) GroupUpdate

func (c *Client) GroupUpdate(groupname, newGroupname, newDescription string) error

GroupUpdate updates a group

func (*Client) IsHTTPS

func (c *Client) IsHTTPS() bool

IsHTTPS returns true if url begins with https

func (*Client) MessageAdd

func (c *Client) MessageAdd(message MessageJSON) (*MessageJSONOut, error)

MessageAdd post a tat message

func (*Client) MessageAddBulk

func (c *Client) MessageAddBulk(messages []MessageJSON) ([]MessageJSONOut, error)

MessageAddBulk post many tat message (root msg or replies)

func (*Client) MessageConcat

func (c *Client) MessageConcat(topic, idMessage string, addText string) (*MessageJSONOut, error)

MessageConcat is same as: ```

curl -XPUT \
    -H 'Content-Type: application/json' \
    -H "Tat_username: username" \
    -H "Tat_password: passwordOfUser" \
	-d '{ "idReference": "9797q87KJhqsfO7Usdqd", "action": "concat", "text": " additional text"}'\
	https://<tatHostname>:<tatPort>/message/topic/sub-topic

```

func (*Client) MessageCount

func (c *Client) MessageCount(topic string, criteria *MessageCriteria) (*MessagesCountJSON, error)

MessageCount count messages on a topic according to criterias

func (*Client) MessageDelete

func (c *Client) MessageDelete(id, topic string, cascade bool, cascadeForce bool) ([]byte, error)

MessageDelete delete a message. cascade : delete message and its replies. cascadeForce : delete message and its replies, event if it's in a Tasks Topic of one user

func (*Client) MessageLabel

func (c *Client) MessageLabel(topic, idMessage string, label Label) (*MessageJSONOut, error)

MessageLabel add a label to a message

func (*Client) MessageLike

func (c *Client) MessageLike(topic, idMessage string) (*MessageJSONOut, error)

MessageLike add a like to a message

func (*Client) MessageList

func (c *Client) MessageList(topic string, criteria *MessageCriteria) (*MessagesJSON, error)

MessageList lists messages on a topic according to criterias

func (*Client) MessageMove

func (c *Client) MessageMove(oldTopic, idMessage, newTopic string) ([]byte, error)

MessageMove moves a message from a topic to another

func (*Client) MessageRelabel

func (c *Client) MessageRelabel(topic, idMessage string, labels []Label, options []string) (*MessageJSONOut, error)

MessageRelabel removes all labels and add new ones to a message

func (*Client) MessageRelabelOrCreate

func (c *Client) MessageRelabelOrCreate(msg MessageJSON) (*MessageJSONOut, error)

MessageRelabelOrCreate removes all labels and add new ones to a message if message exists, create message otherwise

msg := tat.MessageJSON{
  Text:         "a text with a #tag",
  Labels:       []tat.Label{{Text:"textLabel", Color:"red"}},
  TagReference: "a #tag",
  Topic:        "/Internal/YourTopic",
}
if _, err := getClient().MessageRelabelOrCreate(msg); err != nil {
  return fmt.Errorf("Error while MessageAdd:%s", err)
}

func (*Client) MessageReply

func (c *Client) MessageReply(topic, idMessage string, reply string) (*MessageJSONOut, error)

MessageReply post a reply to a message

func (*Client) MessageTask

func (c *Client) MessageTask(topic, idMessage string) (*MessageJSONOut, error)

MessageTask creates a task from a message

func (*Client) MessageUnVoteDown

func (c *Client) MessageUnVoteDown(topic, idMessage string) (*MessageJSONOut, error)

MessageUnVoteDown removes a vote down

func (*Client) MessageUnVoteUP

func (c *Client) MessageUnVoteUP(topic, idMessage string) (*MessageJSONOut, error)

MessageUnVoteUP removes a vote UP from a message

func (*Client) MessageUnlabel

func (c *Client) MessageUnlabel(topic, idMessage, label string) (*MessageJSONOut, error)

MessageUnlabel removes a label from one message

func (*Client) MessageUnlike

func (c *Client) MessageUnlike(topic, idMessage string) (*MessageJSONOut, error)

MessageUnlike removes a like from a message

func (*Client) MessageUntask

func (c *Client) MessageUntask(topic, idMessage string) (*MessageJSONOut, error)

MessageUntask removes doing and doing:username label from a message

func (*Client) MessageUpdate

func (c *Client) MessageUpdate(topic, idMessage string, newText string) (*MessageJSONOut, error)

MessageUpdate updates a message

func (*Client) MessageVoteDown

func (c *Client) MessageVoteDown(topic, idMessage string) (*MessageJSONOut, error)

MessageVoteDown add a vote down to a message

func (*Client) MessageVoteUP

func (c *Client) MessageVoteUP(topic, idMessage string) (*MessageJSONOut, error)

MessageVoteUP add a vote UP to a message

func (*Client) MessagesDeleteBulk

func (c *Client) MessagesDeleteBulk(topic string, cascade bool, cascadeForce bool, criteria MessageCriteria) ([]byte, error)

MessagesDeleteBulk Delete a list of messages delete message and its replies. cascadeForce : delete message and its replies, event if it's in a Tasks Topic of one user

func (*Client) PresenceAddAndGet

func (c *Client) PresenceAddAndGet(topic, status string) (*PresencesJSON, error)

PresenceAddAndGet adds a new presence and get presences on topic

func (*Client) PresenceDelete

func (c *Client) PresenceDelete(topic, username string) error

PresenceDelete deletes a presence

func (*Client) PresenceList

func (c *Client) PresenceList(topic string, skip, limit int) (*PresencesJSON, error)

PresenceList returns presences on topic

func (*Client) StatsCount

func (c *Client) StatsCount() (*StatsCountJSON, error)

StatsCount calls GET /stats/count

func (*Client) StatsDBCollections

func (c *Client) StatsDBCollections() ([]byte, error)

StatsDBCollections returns nb msg for each collections

func (*Client) StatsDBReplSetGetConfig

func (c *Client) StatsDBReplSetGetConfig() ([]byte, error)

StatsDBReplSetGetConfig returns DB Relica Set Config

func (*Client) StatsDBReplSetGetStatus

func (c *Client) StatsDBReplSetGetStatus() ([]byte, error)

StatsDBReplSetGetStatus returns Replica Set Status

func (*Client) StatsDBServerStatus

func (c *Client) StatsDBServerStatus() ([]byte, error)

StatsDBServerStatus returns DB Server Status

func (*Client) StatsDBSlowestQueries

func (c *Client) StatsDBSlowestQueries() ([]byte, error)

StatsDBSlowestQueries returns DB slowest Queries

func (*Client) StatsDBStats

func (c *Client) StatsDBStats() ([]byte, error)

StatsDBStats returns DB Stats

func (*Client) StatsDistributionTopics

func (c *Client) StatsDistributionTopics(skip, limit int) (*StatsDistributionTopicsJSON, error)

StatsDistributionTopics returns Stats Distribution per topics and per users

func (*Client) StatsInstance

func (c *Client) StatsInstance() ([]byte, error)

StatsInstance returns DB Instance

func (*Client) SystemCacheClean

func (c *Client) SystemCacheClean() ([]byte, error)

SystemCacheClean clean cache, only for tat admin

func (*Client) SystemCacheInfo

func (c *Client) SystemCacheInfo() ([]byte, error)

SystemCacheInfo returns cache information

func (*Client) TopicAddAdminGroups

func (c *Client) TopicAddAdminGroups(topic string, groups []string, recursive bool) error

TopicAddAdminGroups adds admin groups on a topic

func (*Client) TopicAddAdminUsers

func (c *Client) TopicAddAdminUsers(topic string, users []string, recursive bool) error

TopicAddAdminUsers adds admin users on a topic

func (*Client) TopicAddFilter

func (c *Client) TopicAddFilter(filter Filter) ([]byte, error)

TopicAddFilter adds a filter on a topic

func (*Client) TopicAddParameter

func (c *Client) TopicAddParameter(topic, key, value string, recursive bool) ([]byte, error)

TopicAddParameter adds a parameter on a topic

func (*Client) TopicAddRoGroups

func (c *Client) TopicAddRoGroups(topic string, groups []string, recursive bool) error

TopicAddRoGroups adds a read-only group on a topic

func (*Client) TopicAddRoUsers

func (c *Client) TopicAddRoUsers(topic string, users []string, recursive bool) error

TopicAddRoUsers adds a read-only user on a topic

func (*Client) TopicAddRwGroups

func (c *Client) TopicAddRwGroups(topic string, groups []string, recursive bool) error

TopicAddRwGroups adds a read-write group on a topic

func (*Client) TopicAddRwUsers

func (c *Client) TopicAddRwUsers(topic string, users []string, recursive bool) error

TopicAddRwUsers adds a read-write user on a topic

func (*Client) TopicAllComputeLabels

func (c *Client) TopicAllComputeLabels() ([]byte, error)

TopicAllComputeLabels computes labels on all topics

func (*Client) TopicAllComputeReplies

func (c *Client) TopicAllComputeReplies() ([]byte, error)

TopicAllComputeReplies computes replies on all topics

func (*Client) TopicAllComputeTags

func (c *Client) TopicAllComputeTags() ([]byte, error)

TopicAllComputeTags computes tags on all topics

func (*Client) TopicAllSetParam

func (c *Client) TopicAllSetParam(p ParamJSON) ([]byte, error)

TopicAllSetParam sets a param on all topics

func (*Client) TopicComputeLabels

func (c *Client) TopicComputeLabels(t TopicNameJSON) ([]byte, error)

TopicComputeLabels computes labels on a topic

func (*Client) TopicComputeTags

func (c *Client) TopicComputeTags(t TopicNameJSON) ([]byte, error)

TopicComputeTags computes tags on a topic

func (*Client) TopicCreate

func (c *Client) TopicCreate(t TopicCreateJSON) (*Topic, error)

TopicCreate creates a topic

func (*Client) TopicDelete

func (c *Client) TopicDelete(t TopicNameJSON) ([]byte, error)

TopicDelete delete a topics

func (*Client) TopicDeleteAdminGroups

func (c *Client) TopicDeleteAdminGroups(topic string, groups []string, recursive bool) error

TopicDeleteAdminGroups deletes some admin groups on a topic

func (*Client) TopicDeleteAdminUsers

func (c *Client) TopicDeleteAdminUsers(topic string, users []string, recursive bool) error

TopicDeleteAdminUsers deletes some admin users on a topic

func (*Client) TopicDeleteParameters

func (c *Client) TopicDeleteParameters(topic string, params []string, recursive bool) error

TopicDeleteParameters removes a parameter on a topic

func (*Client) TopicDeleteRoGroups

func (c *Client) TopicDeleteRoGroups(topic string, groups []string, recursive bool) error

TopicDeleteRoGroups deletes a read-only group on a topic

func (*Client) TopicDeleteRoUsers

func (c *Client) TopicDeleteRoUsers(topic string, users []string, recursive bool) error

TopicDeleteRoUsers deletes a read-only user on a topic

func (*Client) TopicDeleteRwGroups

func (c *Client) TopicDeleteRwGroups(topic string, groups []string, recursive bool) error

TopicDeleteRwGroups deletes some read-write groups on a topic

func (*Client) TopicDeleteRwUsers

func (c *Client) TopicDeleteRwUsers(topic string, users []string, recursive bool) error

TopicDeleteRwUsers deletes some read-write users on a topic

func (*Client) TopicList

func (c *Client) TopicList(criteria *TopicCriteria) (*TopicsJSON, error)

TopicList list all topics according to criterias. Default behavior (criteria is Nil) will limit 10 topics.

func (*Client) TopicOne

func (c *Client) TopicOne(topic string) (*TopicJSON, error)

TopicOne returns one topic, and flags isUserRW / isUserAdmin on topic

func (*Client) TopicParameter

func (c *Client) TopicParameter(params TopicParameters) ([]byte, error)

TopicParameter updates param on one topic

func (*Client) TopicRemoveFilter

func (c *Client) TopicRemoveFilter(filter Filter) ([]byte, error)

TopicDeleteFilters removes a filter on a topic

func (*Client) TopicTruncate

func (c *Client) TopicTruncate(t TopicNameJSON) ([]byte, error)

TopicTruncate deletes all messages in a topic

func (*Client) TopicTruncateLabels

func (c *Client) TopicTruncateLabels(t TopicNameJSON) ([]byte, error)

TopicTruncateLabels removes all labels computed on topic

func (*Client) TopicTruncateTags

func (c *Client) TopicTruncateTags(t TopicNameJSON) ([]byte, error)

TopicTruncateTags removes all tags computed on topic

func (*Client) TopicUpdateFilter

func (c *Client) TopicUpdateFilter(filter Filter) ([]byte, error)

TopicUpdateFilters removes a filter on a topic

func (*Client) UserAdd

func (c *Client) UserAdd(u UserCreateJSON) ([]byte, error)

UserAdd creates a new user if callback is "", "tatcli --url=:scheme://:host::port:path user verify --save :username :token" will be used

func (*Client) UserAddContact

func (c *Client) UserAddContact(toAdd string) ([]byte, error)

UserAddContact adds a contact

func (*Client) UserAddFavoriteTag

func (c *Client) UserAddFavoriteTag(toAdd string) ([]byte, error)

UserAddFavoriteTag adds a favorite tag to current user

func (*Client) UserAddFavoriteTopic

func (c *Client) UserAddFavoriteTopic(toAdd string) ([]byte, error)

UserAddFavoriteTopic adds a favorite topic on current user

func (*Client) UserArchive

func (c *Client) UserArchive(username string) error

UserArchive archives a user

func (*Client) UserCheck

func (c *Client) UserCheck(check CheckTopicsUserJSON) ([]byte, error)

UserCheck checks if user have default topics

func (*Client) UserContacts

func (c *Client) UserContacts(sinceSeconds int) ([]byte, error)

UserContacts returns contacts presences since n seconds

func (*Client) UserConvertToSystem

func (c *Client) UserConvertToSystem(s ConvertUserJSON) ([]byte, error)

UserConvertToSystem converts a user to a system user

func (*Client) UserDisableNotificationsAllTopics

func (c *Client) UserDisableNotificationsAllTopics() ([]byte, error)

UserDisableNotificationsAllTopics disable notification on all topics

func (*Client) UserDisableNotificationsTopic

func (c *Client) UserDisableNotificationsTopic(topic string) ([]byte, error)

UserDisableNotificationsTopic disables notifications on one topic

func (*Client) UserEnableNotificationsAllTopics

func (c *Client) UserEnableNotificationsAllTopics() ([]byte, error)

UserEnableNotificationsAllTopics enables notification on all topics

func (*Client) UserEnableNotificationsTopic

func (c *Client) UserEnableNotificationsTopic(topic string) ([]byte, error)

UserEnableNotificationsTopic enables notifications on one topic

func (*Client) UserList

func (c *Client) UserList(criteria *UserCriteria) (*UsersJSON, error)

UserList returns all users

func (*Client) UserMe

func (c *Client) UserMe() (*UserJSON, error)

UserMe returns current user

func (*Client) UserRemoveContact

func (c *Client) UserRemoveContact(toRemove string) ([]byte, error)

UserRemoveContact removes a contact from a user

func (*Client) UserRemoveFavoriteTag

func (c *Client) UserRemoveFavoriteTag(toRemove string) ([]byte, error)

UserRemoveFavoriteTag removes a favorite tag from current user

func (*Client) UserRemoveFavoriteTopic

func (c *Client) UserRemoveFavoriteTopic(toRemove string) ([]byte, error)

UserRemoveFavoriteTopic remove a favorite topic from current user

func (*Client) UserRename

func (c *Client) UserRename(v RenameUserJSON) ([]byte, error)

UserRename renames a user

func (*Client) UserReset

func (c *Client) UserReset(v UserResetJSON) ([]byte, error)

UserReset is used for reset password for a user

func (*Client) UserResetSystem

func (c *Client) UserResetSystem(v UsernameUserJSON) ([]byte, error)

UserResetSystem is used for reset password for a system user

func (*Client) UserSetAdmin

func (c *Client) UserSetAdmin(u UsernameUserJSON) ([]byte, error)

UserSetAdmin set a user as an admin

func (*Client) UserUpdate

func (c *Client) UserUpdate(v UpdateUserJSON) ([]byte, error)

UserUpdate is used for update current user

func (*Client) UserUpdateSystem

func (c *Client) UserUpdateSystem(u ConvertUserJSON) ([]byte, error)

UserUpdateSystem updates a system user

func (*Client) UserVerify

func (c *Client) UserVerify(username, tokenVerify string) (*VerifyJSON, error)

UserVerify is used for verify user and returns password

func (*Client) Version

func (c *Client) Version() ([]byte, error)

Version returns Tat Engine version

type Contact

type Contact struct {
	Username string `bson:"username" json:"username"`
	Fullname string `bson:"fullname" json:"fullname"`
}

Contact User Struct.

type ContactsJSON

type ContactsJSON struct {
	Contacts               []Contact   `json:"contacts"`
	CountContactsPresences int         `json:"countContactsPresences"`
	ContactsPresences      *[]Presence `json:"contactsPresence"`
}

ContactsJSON represents a contact for a user, in contacts attribute on a user

type ConvertUserJSON

type ConvertUserJSON struct {
	Username            string `json:"username" binding:"required"`
	CanListUsersAsAdmin bool   `json:"canListUsersAsAdmin" binding:"required"`
}

ConvertUserJSON is used to convert a user to a system user

type Filter

type Filter struct {
	Topic    string         `bson:"-" json:"topic"`
	ID       string         `bson:"_id" json:"_id"`
	UserID   string         `bson:"userID" json:"userID"`
	Username string         `bson:"username" json:"username"`
	Title    string         `bson:"title" json:"title"`
	Criteria FilterCriteria `bson:"criteria" json:"criteria"`
	Hooks    []Hook         `bson:"hooks" json:"hooks"`
}

type FilterCriteria

type FilterCriteria struct {
	Label       string `bson:"label" json:"label,omitempty"`
	NotLabel    string `bson:"notLabel" json:"notLabel,omitempty"`
	AndLabel    string `bson:"andLabel" json:"andLabel,omitempty"`
	Tag         string `bson:"tag" json:"tag,omitempty"`
	NotTag      string `bson:"notTag" json:"notTag,omitempty"`
	AndTag      string `bson:"andTag" json:"andTag,omitempty"`
	Username    string `bson:"username" json:"username,omitempty"`
	OnlyMsgRoot bool   `bson:"onlyMsgRoot" json:"onlyMsgRoot"`
}

FilterCriteria are used to list messages

func (FilterCriteria) FilterCriteriaIsEmpty

func (c FilterCriteria) FilterCriteriaIsEmpty() bool

type Group

type Group struct {
	ID           string   `bson:"_id"          json:"_id"`
	Name         string   `bson:"name"         json:"name"`
	Description  string   `bson:"description"  json:"description"`
	Users        []string `bson:"users"        json:"users,omitempty"`
	AdminUsers   []string `bson:"adminUsers"   json:"adminUsers,omitempty"`
	DateCreation int64    `bson:"dateCreation" json:"dateCreation,omitempty"`
}

Group struct

type GroupCriteria

type GroupCriteria struct {
	Skip            int
	Limit           int
	IDGroup         string
	Name            string
	NameRegex       string
	Description     string
	DateMinCreation string
	DateMaxCreation string
	UserUsername    string
	SortBy          string
}

GroupCriteria is used by List all Groups

func (*GroupCriteria) CacheKey

func (g *GroupCriteria) CacheKey() []string

CacheKey returns cacke key value

type GroupJSON

type GroupJSON struct {
	Name        string `json:"name" binding:"required"`
	Description string `json:"description" binding:"required"`
}

GroupJSON contains name and description for a group

type GroupsJSON

type GroupsJSON struct {
	Count  int     `json:"count"`
	Groups []Group `json:"groups"`
}

GroupsJSON is used by Tat Engine, for groups list

type Hook

type Hook struct {
	ID          string `bson:"_id" json:"_id"`
	Type        string `bson:"type" json:"type"` // in HooksType
	Destination string `bson:"destination" json:"destination"`
	Errors      int    `bson:"errors" json:"errors"`
	Enabled     bool   `bson:"enabled" json:"enabled"`
	Item        string `json:"item"`   // only "message" for now
	Action      string `json:"action"` // MessageActionVoteup, MessageActionCreate, etc...
}

type HookJSON

type HookJSON struct {
	Hook        Hook             `json:"hook"`
	HookMessage *HookMessageJSON `json:"hookMessage"`
	Username    string           `json:"username"`
}

HookJSON represents a json sent to an external system

type HookMessageJSON

type HookMessageJSON struct {
	Action         string          `json:"action"`
	MessageJSONOut *MessageJSONOut `json:"message"`
}

HookMessageJSON represents a json sent to an external system, for a event about a message

type Label

type Label struct {
	Text  string `bson:"text" json:"text"`
	Color string `bson:"color" json:"color"`
}

Label struct

type Message

type Message struct {
	ID              string    `bson:"_id"             json:"_id"`
	Text            string    `bson:"text"            json:"text"`
	Topic           string    `bson:"topic"           json:"topic"`
	InReplyOfID     string    `bson:"inReplyOfID"     json:"inReplyOfID"`
	InReplyOfIDRoot string    `bson:"inReplyOfIDRoot" json:"inReplyOfIDRoot"`
	NbLikes         int64     `bson:"nbLikes"         json:"nbLikes"`
	Labels          []Label   `bson:"labels"          json:"labels,omitempty"`
	Likers          []string  `bson:"likers"          json:"likers,omitempty"`
	VotersUP        []string  `bson:"votersUP"        json:"votersUP,omitempty"`
	VotersDown      []string  `bson:"votersDown"      json:"votersDown,omitempty"`
	NbVotesUP       int64     `bson:"nbVotesUP"       json:"nbVotesUP"`
	NbVotesDown     int64     `bson:"nbVotesDown"     json:"nbVotesDown"`
	UserMentions    []string  `bson:"userMentions"    json:"userMentions,omitempty"`
	Urls            []string  `bson:"urls"            json:"urls,omitempty"`
	Tags            []string  `bson:"tags"            json:"tags,omitempty"`
	DateCreation    float64   `bson:"dateCreation"    json:"dateCreation"`
	DateUpdate      float64   `bson:"dateUpdate"      json:"dateUpdate"`
	Author          Author    `bson:"author"          json:"author"`
	Replies         []Message `bson:"-"               json:"replies,omitempty"`
	NbReplies       int64     `bson:"nbReplies"       json:"nbReplies"`
}

Message struc

func (*Message) ContainsLabel

func (m *Message) ContainsLabel(label string) bool

ContainsLabel returns true if message contains label

func (*Message) ContainsTag

func (m *Message) ContainsTag(tag string) bool

ContainsTag returns true if message contains tag

func (*Message) Format

func (m *Message) Format(format string, tatwebuiBaseURL string) (string, error)

Format return string formatted message

default format: format:dateUpdate,username,text,labels

Avalable fields: id,text,topic,inReplyOfID,inReplyOfIDRoot,nbLikes,labels, votersUP,votersDown,nbVotesUP,nbVotesDown,userMentions, urls,tags,dateCreation,dateUpdate,username,fullname,nbReplies,tatwebuiURL

func (*Message) GetLabel

func (m *Message) GetLabel(label string) (int, Label, error)

GetLabel returns label, and position if message contains label

func (*Message) GetTag

func (m *Message) GetTag(tag string) (int, string, error)

GetTag returns position, tag is message contains tag

func (*Message) IsDoing

func (m *Message) IsDoing() bool

IsDoing returns true if message contains label doing or starts with doing:

type MessageCriteria

type MessageCriteria struct {
	Skip                    int
	Limit                   int
	TreeView                string
	IDMessage               string
	InReplyOfID             string
	InReplyOfIDRoot         string
	AllIDMessage            string // search in IDMessage OR InReplyOfID OR InReplyOfIDRoot
	Text                    string
	Topic                   string
	Label                   string `bson:"label" json:"label,omitempty"`
	StartLabel              string `bson:"startLabel" json:"startLabel,omitempty"`
	NotLabel                string `bson:"notLabel" json:"notLabel,omitempty"`
	AndLabel                string `bson:"andLabel" json:"andLabel,omitempty"`
	Tag                     string `bson:"tag" json:"tag,omitempty"`
	StartTag                string `bson:"startTag" json:"startTag,omitempty"`
	NotTag                  string `bson:"notTag" json:"notTag,omitempty"`
	AndTag                  string `bson:"andTag" json:"andTag,omitempty"`
	Username                string `bson:"username" json:"username,omitempty"`
	DateMinCreation         string
	DateMaxCreation         string
	DateMinUpdate           string
	DateMaxUpdate           string
	LastMinCreation         string
	LastMaxCreation         string
	LastMinUpdate           string
	LastMaxUpdate           string
	LastHourMinCreation     string
	LastHourMaxCreation     string
	LastHourMinUpdate       string
	LastHourMaxUpdate       string
	DateRefCreation         string
	DateRefDeltaMinCreation string
	DateRefDeltaMaxCreation string
	DateRefUpdate           string
	DateRefDeltaMinUpdate   string
	DateRefDeltaMaxUpdate   string
	LimitMinNbReplies       string
	LimitMaxNbReplies       string
	LimitMinNbVotesUP       string
	LimitMinNbVotesDown     string
	LimitMaxNbVotesUP       string
	LimitMaxNbVotesDown     string
	OnlyMsgRoot             string `bson:"onlyMsgRoot" json:"onlyMsgRoot,omitempty"`
	OnlyMsgReply            string `bson:"onlyMsgReply" json:"onlyMsgReply,omitempty"`
	OnlyCount               string
	SortBy                  string `bson:"sortBy" json:"sortBy"`
}

MessageCriteria are used to list messages

func GetMessageCriteriaFromURLValues

func GetMessageCriteriaFromURLValues(values url.Values) (*MessageCriteria, error)

GetMessageCriteriaFromURLValues returns a MessagesCriteria from a url.Values

func (*MessageCriteria) CacheKey

func (m *MessageCriteria) CacheKey() []string

CacheKey returns cache key value

func (*MessageCriteria) GetURL

func (m *MessageCriteria) GetURL() string

GetURL returns URL for messageCriteria

type MessageJSON

type MessageJSON struct {
	ID                  string `json:"_id"`
	Text                string `json:"text"`
	Option              string `json:"option"`
	Topic               string
	IDReference         string        `json:"idReference"`
	StartTagReference   string        `json:"startTagReference"`
	StartLabelReference string        `json:"startLabelReference"`
	TagReference        string        `json:"tagReference"`
	LabelReference      string        `json:"labelReference"`
	OnlyRootReference   string        `json:"onlyRootReference"`
	Action              string        `json:"action"`
	DateCreation        float64       `json:"dateCreation"`
	Labels              []Label       `json:"labels"`
	Options             []string      `json:"options"`
	Replies             []string      `json:"replies"`
	Messages            []MessageJSON `json:"messages"` // same as replies, but with Labels...
}

MessageJSON represents a message with action on it

type MessageJSONOut

type MessageJSONOut struct {
	Message Message `json:"message"`
	Info    string  `json:"info"`
}

MessageJSONOut represents a message and an additional info

type MessageReferenceJSON

type MessageReferenceJSON struct {
	TagReference        string `json:"tagReference"`
	StartTagReference   string `json:"startTagReference"`
	LabelReference      string `json:"labelReference"`
	StartLabelReference string `json:"startLabelReference"`
	IDReference         string `json:"idReference"`
}

MessageReferenceJSON is used for and action On A Existing Message

type MessagesCountJSON

type MessagesCountJSON struct {
	Count int `json:"count"`
}

MessagesCountJSON represents count of messages

type MessagesJSON

type MessagesJSON struct {
	Messages     []Message `json:"messages"`
	IsTopicRw    bool      `json:"isTopicRw"`
	IsTopicAdmin bool      `json:"isTopicAdmin"`
}

MessagesJSON represents a message and information if current topic is RW

type MessagesJSONIn

type MessagesJSONIn struct {
	Messages []*MessageJSON `json:"messages"`
}

type Options

type Options struct {
	Username              string
	Password              string
	BasicAuthUsername     string
	BasicAuthPassword     string
	URL                   string
	Referer               string
	RequestTimeout        time.Duration
	MaxTries              uint
	SSLInsecureSkipVerify bool
}

Options is a struct to initialize a TAT client

type ParamGroupUserJSON

type ParamGroupUserJSON struct {
	Groupname string `json:"groupname"`
	Username  string `json:"username"`
}

ParamGroupUserJSON is used for add or remove user on a group

type ParamJSON

type ParamJSON struct {
	ParamName  string `json:"paramName"`
	ParamValue string `json:"paramValue"`
}

ParamJSON is used to update a param on a topic (attr. Parameters on Topic struct)

type ParamTopicGroupJSON

type ParamTopicGroupJSON struct {
	Topic     string `json:"topic"`
	Groupname string `json:"groupname"`
	Recursive bool   `json:"recursive"`
}

ParamTopicGroupJSON is used for manipulate a group on a topic

type ParamTopicUserJSON

type ParamTopicUserJSON struct {
	Topic     string `json:"topic"` // topic topic
	Username  string `json:"username"`
	Recursive bool   `json:"recursive"`
}

ParamTopicUserJSON is used to update a parameter on topic

type Presence

type Presence struct {
	ID               string       `bson:"_id,omitempty"    json:"_id"`
	Status           string       `bson:"status"           json:"status"`
	Topic            string       `bson:"topic"            json:"topic"`
	DatePresence     int64        `bson:"datePresence"     json:"datePresence"`
	DateTimePresence time.Time    `bson:"dateTimePresence" json:"dateTimePresence"`
	UserPresence     UserPresence `bson:"userPresence"     json:"userPresence"`
}

Presence struct

type PresenceCriteria

type PresenceCriteria struct {
	Skip            int
	Limit           int
	IDPresence      string
	Status          string
	Topic           string
	Username        string
	DateMinPresence string
	DateMaxPresence string
	SortBy          string
}

PresenceCriteria used by Presences List

type PresenceJSON

type PresenceJSON struct {
	Status   string `json:"status" binding:"required"`
	Username string `json:"username,omitempty"`
	Topic    string
}

PresenceJSON represents a status on a topic

type PresenceJSONOut

type PresenceJSONOut struct {
	Presence Presence `json:"presence"`
}

PresenceJSONOut represents a presence

type PresencesJSON

type PresencesJSON struct {
	Count     int        `json:"count"`
	Presences []Presence `json:"presences"`
}

PresencesJSON represents list of presences with count for total

type RenameUserJSON

type RenameUserJSON struct {
	Username    string `json:"username"  binding:"required"`
	NewUsername string `json:"newUsername"  binding:"required"`
}

RenameUserJSON is used for rename a user

type StatsCountJSON

type StatsCountJSON struct {
	Date      int64     `json:"date"`
	DateHuman time.Time `json:"dateHuman"`
	Version   string    `json:"version"`
	Groups    int       `json:"groups"`
	Messages  int       `json:"messages"`
	Presences int       `json:"presences"`
	Topics    int       `json:"topics"`
	Users     int       `json:"users"`
}

StatsCountJSON contains all globals counters

type StatsDistributionTopicsJSON

type StatsDistributionTopicsJSON struct {
	Total  int                     `json:"total"`
	Info   string                  `json:"info"`
	Topics []TopicDistributionJSON `json:"topics"`
}

StatsDistributionTopicsJSON is used by GET /distribution/topics

type Topic

type Topic struct {
	ID                   string           `bson:"_id" json:"_id,omitempty"`
	Collection           string           `bson:"collection" json:"collection"`
	Topic                string           `bson:"topic" json:"topic"`
	Description          string           `bson:"description" json:"description"`
	ROGroups             []string         `bson:"roGroups" json:"roGroups,omitempty"`
	RWGroups             []string         `bson:"rwGroups" json:"rwGroups,omitempty"`
	ROUsers              []string         `bson:"roUsers" json:"roUsers,omitempty"`
	RWUsers              []string         `bson:"rwUsers" json:"rwUsers,omitempty"`
	AdminUsers           []string         `bson:"adminUsers" json:"adminUsers,omitempty"`
	AdminGroups          []string         `bson:"adminGroups" json:"adminGroups,omitempty"`
	History              []string         `bson:"history" json:"history"`
	MaxLength            int              `bson:"maxlength" json:"maxlength"`
	MaxReplies           int              `bson:"maxreplies" json:"maxreplies"`
	CanForceDate         bool             `bson:"canForceDate" json:"canForceDate"`
	CanUpdateMsg         bool             `bson:"canUpdateMsg" json:"canUpdateMsg"`
	CanDeleteMsg         bool             `bson:"canDeleteMsg" json:"canDeleteMsg"`
	CanUpdateAllMsg      bool             `bson:"canUpdateAllMsg" json:"canUpdateAllMsg"`
	CanDeleteAllMsg      bool             `bson:"canDeleteAllMsg" json:"canDeleteAllMsg"`
	AdminCanUpdateAllMsg bool             `bson:"adminCanUpdateAllMsg" json:"adminCanUpdateAllMsg"`
	AdminCanDeleteAllMsg bool             `bson:"adminCanDeleteAllMsg" json:"adminCanDeleteAllMsg"`
	IsAutoComputeTags    bool             `bson:"isAutoComputeTags" json:"isAutoComputeTags"`
	IsAutoComputeLabels  bool             `bson:"isAutoComputeLabels" json:"isAutoComputeLabels"`
	DateModification     int64            `bson:"dateModification" json:"dateModificationn,omitempty"`
	DateCreation         int64            `bson:"dateCreation" json:"dateCreation,omitempty"`
	DateLastMessage      int64            `bson:"dateLastMessage" json:"dateLastMessage,omitempty"`
	Parameters           []TopicParameter `bson:"parameters" json:"parameters,omitempty"`
	Tags                 []string         `bson:"tags" json:"tags,omitempty"`
	Labels               []Label          `bson:"labels" json:"labels,omitempty"`
	Filters              []Filter         `bson:"filters" json:"filters"`
}

Topic struct

type TopicCreateJSON

type TopicCreateJSON struct {
	Topic       string `json:"topic" binding:"required"`
	Description string `json:"description" binding:"required"`
}

TopicCreateJSON is used to create a parameter on topic

type TopicCriteria

type TopicCriteria struct {
	Skip                 int
	Limit                int
	IDTopic              string
	Topic                string
	TopicPath            string
	Description          string
	DateMinCreation      string
	DateMaxCreation      string
	GetNbMsgUnread       string
	OnlyFavorites        string
	GetForTatAdmin       string
	GetForAllTasksTopics bool
	Group                string
	SortBy               string
}

TopicCriteria struct, used by List Topic

func (*TopicCriteria) CacheKey

func (t *TopicCriteria) CacheKey() []string

CacheKey returns cache key value

type TopicDistributionJSON

type TopicDistributionJSON struct {
	ID         string `json:"id"`
	Topic      string `json:"topic"`
	Count      int    `json:"count"`
	Dedicated  bool   `json:"dedicated"`
	Collection string `json:"collection"`
}

TopicDistributionJSON represents struct used by Engine while returns topic distribution

type TopicJSON

type TopicJSON struct {
	Topic        *Topic `json:"topic"`
	IsTopicRw    bool   `json:"isTopicRw"`
	IsTopicAdmin bool   `json:"isTopicAdmin"`
}

TopicJSON represents struct used by Engine while returns one topic

type TopicNameJSON

type TopicNameJSON struct {
	Topic string `json:"topic"`
}

TopicNameJSON represents struct, only topic name

type TopicParameter

type TopicParameter struct {
	Key   string `bson:"key"   json:"key"`
	Value string `bson:"value" json:"value"`
}

TopicParameter struct, parameter on topics

type TopicParameterJSON

type TopicParameterJSON struct {
	Topic     string `json:"topic"`
	Key       string `json:"key"`
	Value     string `json:"value"`
	Recursive bool   `json:"recursive"`
}

TopicParameterJSON is used to manipulate a parameter on a topic

type TopicParameters

type TopicParameters struct {
	Topic                string `json:"topic"`
	MaxLength            int    `json:"maxlength"`
	MaxReplies           int    `json:"maxreplies"`
	CanForceDate         bool   `json:"canForceDate"`
	CanUpdateMsg         bool   `json:"canUpdateMsg"`
	CanDeleteMsg         bool   `json:"canDeleteMsg"`
	CanUpdateAllMsg      bool   `json:"canUpdateAllMsg"`
	CanDeleteAllMsg      bool   `json:"canDeleteAllMsg"`
	AdminCanUpdateAllMsg bool   `json:"adminCanUpdateAllMsg"`
	AdminCanDeleteAllMsg bool   `json:"adminCanDeleteAllMsg"`
	IsAutoComputeTags    bool   `json:"isAutoComputeTags"`
	IsAutoComputeLabels  bool   `json:"isAutoComputeLabels"`
	Recursive            bool   `json:"recursive"`
}

TopicParameters updates param on one topic

type TopicsJSON

type TopicsJSON struct {
	Count                int            `json:"count"`
	Topics               []Topic        `json:"topics"`
	CountTopicsMsgUnread int            `json:"countTopicsMsgUnread"`
	TopicsMsgUnread      map[string]int `json:"topicsMsgUnread"`
}

TopicsJSON represents struct used by Engine while returns list of topics

type UpdateUserJSON

type UpdateUserJSON struct {
	Username    string `json:"username" binding:"required"`
	NewFullname string `json:"newFullname" binding:"required"`
	NewEmail    string `json:"newEmail" binding:"required"`
}

UpdateUserJSON is used for update user information

type User

type User struct {
	ID                     string    `bson:"_id" json:"_id"`
	Username               string    `bson:"username" json:"username"`
	Fullname               string    `bson:"fullname" json:"fullname"`
	Email                  string    `bson:"email" json:"email,omitempty"`
	Groups                 []string  `bson:"-" json:"groups,omitempty"`
	IsAdmin                bool      `bson:"isAdmin" json:"isAdmin,omitempty"`
	IsSystem               bool      `bson:"isSystem" json:"isSystem,omitempty"`
	IsArchived             bool      `bson:"isArchived" json:"isArchived,omitempty"`
	CanListUsersAsAdmin    bool      `bson:"canListUsersAsAdmin" json:"canListUsersAsAdmin,omitempty"`
	FavoritesTopics        []string  `bson:"favoritesTopics" json:"favoritesTopics,omitempty"`
	OffNotificationsTopics []string  `bson:"offNotificationsTopics" json:"offNotificationsTopics,omitempty"`
	FavoritesTags          []string  `bson:"favoritesTags" json:"favoritesTags,omitempty"`
	DateCreation           int64     `bson:"dateCreation" json:"dateCreation,omitempty"`
	Contacts               []Contact `bson:"contacts" json:"contacts,omitempty"`
	Auth                   Auth      `bson:"auth" json:"-"`
}

User struct

type UserCreateJSON

type UserCreateJSON struct {
	Username string `json:"username"  binding:"required"`
	Fullname string `json:"fullname"  binding:"required"`
	Email    string `json:"email"     binding:"required"`
	// Callback contains command to execute to verify account
	// this command is displayed in ask for confirmation mail
	Callback string `json:"callback"`
}

UserCreateJSON is used for create a new user

type UserCriteria

type UserCriteria struct {
	Skip            int
	Limit           int
	WithGroups      bool
	IDUser          string
	Username        string
	Fullname        string
	DateMinCreation string
	DateMaxCreation string
	SortBy          string
}

UserCriteria is used to list users with criterias

type UserJSON

type UserJSON struct {
	User User `json:"user"`
}

UserJSON used by GET /user/me

type UserPresence

type UserPresence struct {
	Username string `bson:"username" json:"username"`
	Fullname string `bson:"fullname" json:"fullname"`
}

UserPresence struct

type UserResetJSON

type UserResetJSON struct {
	Username string `json:"username"  binding:"required"`
	Email    string `json:"email"     binding:"required"`
	// Callback contains command to execute to verify account
	// this command is displayed in ask for confirmation mail
	Callback string `json:"callback"`
}

UserResetJSON is used for reset a new user

type UsernameUserJSON

type UsernameUserJSON struct {
	Username string `json:"username" binding:"required"`
}

UsernameUserJSON contains just a username

type UsersJSON

type UsersJSON struct {
	Count int    `json:"count"`
	Users []User `json:"users"`
}

UsersJSON represents list of users and count for total

type VerifyJSON

type VerifyJSON struct {
	Message  string `json:"message,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	URL      string `json:"url,omitempty"`
}

VerifyJSON is used for returns password for a user with verify action

Jump to

Keyboard shortcuts

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