gostashcat

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelInfo

type ChannelInfo struct {
	ID int
	ChannelInfoRadikal
}

type ChannelInfoIDInt

type ChannelInfoIDInt struct {
	ID int `json:"id"`
	ChannelInfoRadikal
}

type ChannelInfoIDString

type ChannelInfoIDString struct {
	ID int `json:"id,string"`
	ChannelInfoRadikal
}

type ChannelInfoRadikal

type ChannelInfoRadikal struct {
	Name string `json:"name"`
	// Image
	Description string `json:"description"`
	// GroupID
	// LDAPName
	CompanyID string `json:"company"`
	Type      string `json:"type"`
	Visible   bool   `json:"visible"`
	// Password
	Encrypted                bool           `json:"encrypted"`
	LastAction               string         `json:"last_action"`
	LastActivity             FlexInt        `json:"last_activity"`
	Writable                 string         `json:"writable"`
	Inviteable               string         `json:"inviteable"`
	CanLeave                 bool           `json:"can_leave"`
	ShowMembershipActivities bool           `json:"show_membership_activities"`
	UserCount                int            `json:"user_count"`
	PendingCount             int            `json:"pending_count"`
	NumMembersWithoutKeys    int            `json:"num_members_without_keys"`
	Membership               MembershipInfo `json:"membership"`
	Key                      string         `json:"key"`
	// KeyRequested
	Unread int `json:"unread"`
}

type ChannelInfoResponse

type ChannelInfoResponse struct {
	Status    Status                     `json:"status"`
	Payload   ChannelInfoResponsePayload `json:"payload"`
	Signature string                     `json:"signature"`
}

type ChannelInfoResponsePayload

type ChannelInfoResponsePayload struct {
	Channel ChannelInfoIDInt `json:"channels"`
}

type CheckResponse

type CheckResponse struct {
	Status    Status               `json:"status"`
	Payload   CheckResponsePayload `json:"payload"`
	Signature string               `json:"signature"`
}

CheckResponse is the structure returned by a call to /auth/check

type CheckResponsePayload

type CheckResponsePayload struct {
	Success bool `json:"success"`
}

CheckResponsePayload is the structure returned in the payload of a call to /auth/check

type Client

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

Client for the stashcat API

func New

func New(cc ClientConfig) *Client

func (*Client) Check

func (api *Client) Check() (bool, error)

Check validates if the current client_key is still valid

func (*Client) CreateConversation

func (api *Client) CreateConversation(users []User) (Conversation, error)

func (*Client) Debugf

func (api *Client) Debugf(format string, v ...interface{})

Debugf print a formatted debug line

func (*Client) Debugln

func (api *Client) Debugln(v ...interface{})

Debugln print a debug line

func (*Client) DecryptMessages

func (api *Client) DecryptMessages(messages []Message, encryptedKey string) ([]Message, error)

func (*Client) GetChannelContent

func (api *Client) GetChannelContent(channel ChannelInfo, limit, offset int) ([]Message, error)

func (*Client) GetChannelInfo

func (api *Client) GetChannelInfo(channelID int) (ChannelInfo, error)

func (*Client) GetConversationContent

func (api *Client) GetConversationContent(conversation Conversation, limit, offset int) ([]Message, error)

func (*Client) GetFile

func (api *Client) GetFile(f File) (string, error)

func (*Client) GetFolderContent

func (api *Client) GetFolderContent(ch ChannelInfo, fID, limit, offset int) (FolderGetResponseContent, error)

func (*Client) GetFromCache

func (api *Client) GetFromCache() error

GetFromCache retrieves the client_key from a cache file, validates it and does a login if validation does not succeed

func (*Client) GetMessageByHash added in v0.3.1

func (api *Client) GetMessageByHash(hash string) (Message, error)

func (*Client) GetSubscribedChannels

func (api *Client) GetSubscribedChannels() ([]ChannelInfo, error)

func (*Client) GetUserInfo

func (api *Client) GetUserInfo(userID int) (User, error)

func (*Client) GetUserMe

func (api *Client) GetUserMe() (User, error)

func (*Client) ListUsers

func (api *Client) ListUsers(limit int, offset int, search string) ([]User, error)

func (*Client) LoadPrivateKey

func (api *Client) LoadPrivateKey(encryptionPassword string) error

LoadPrivateKey retrieves the encrypted private key and decrypts it

func (*Client) Login

func (api *Client) Login() error

Login authenticates with the stashcat api

func (*Client) ManageListUsers

func (api *Client) ManageListUsers(limit int, offset int, search string, companyID string) ([]User, error)

func (*Client) SendAlarmMessageToConversation

func (api *Client) SendAlarmMessageToConversation(conversation Conversation, plainMessage string) (Message, error)

func (*Client) SendAlarmMessageToUser

func (api *Client) SendAlarmMessageToUser(userID int, message string) (Message, error)

Wrapper to creating a new conversation with user and sending a message to it

func (*Client) SendMessageToChannel

func (api *Client) SendMessageToChannel(channel ChannelInfo, plainMessage string) (Message, error)

func (*Client) SendMessageToConversation

func (api *Client) SendMessageToConversation(conversation Conversation, plainMessage string) (Message, error)

func (*Client) SendMessageToUser

func (api *Client) SendMessageToUser(userID int, message string) (Message, error)

SendMessageToUser is a wrapper to creating a new conversation with a single user and sending a message to it

func (*Client) SetDebug

func (api *Client) SetDebug()

SetDebug enables debug mode

func (*Client) SetLogger

func (api *Client) SetLogger(logger *log.Logger)

type ClientConfig

type ClientConfig struct {
	Email              string
	Password           string
	AppName            string
	APIURL             string
	CacheClientKeyPath string
	DeviceID           string
}

type Conversation

type Conversation struct {
	ID           string `json:"id"`
	Name         string `json:"name,omitempty"`
	Created      string `json:"created"`
	LastAction   string `json:"last_action"`
	LastActivity string `json:"last_activity"`
	Encrypted    bool   `json:"encrypted"`

	UserCount      int    `json:"user_count"`
	UnreadMessages int    `json:"unread_messages"`
	Key            string `json:"key"`
}

type ConversationResponse

type ConversationResponse struct {
	Status    Status                      `json:"status"`
	Payload   ConversationResponsePayload `json:"payload"`
	Signature string                      `json:"signature"`
}

type ConversationResponsePayload

type ConversationResponsePayload struct {
	Conversation Conversation `json:"conversation"`
}

type File

type File struct {
	ID              int    `json:"id,string"`
	Name            string `json:"name"`
	SizeBytes       int    `json:"size_byte,string"`
	TypeID          int    `json:"type_id,string"`
	Ext             string `json:"ext"`
	Mime            string `json:"mime"`
	Uploaded        int    `json:"uploaded,string"`
	Modified        int    `json:"modified,string"`
	OwnerID         int    `json:"owner_id,string"`
	LastDownload    int    `json:"last_download,string"`
	TimesDownloaded int    `json:"times_downloaded,string"`
	Encrypted       bool   `json:"encrypted"`
	E2EIV           string `json:"e2e_iv"`
	MD5             string `json:"md5"`
	Keys            []Key  `json:"keys"`
}

type FlexInt

type FlexInt int

func (*FlexInt) UnmarshalJSON

func (fi *FlexInt) UnmarshalJSON(b []byte) error

type Folder

type Folder struct {
	ID       int    `json:"id,string"`
	ParentID int    `json:"parent_id,string,omitempty"`
	Type     string `json:"type"`
	TypeID   int    `json:"type_id,string"`
	Name     string `json:"name"`
	Creator  int    `json:"creator,string"`
	Modified int    `json:"modified,string"`
}

type FolderGetResponse

type FolderGetResponse struct {
	Status    Status                   `json:"status"`
	Payload   FolderGetResponsePayload `json:"payload"`
	Signature string                   `json:"signature"`
}

type FolderGetResponseContent

type FolderGetResponseContent struct {
	Folder     []Folder `json:"folder"`
	Files      []File   `json:"files"`
	Permission string   `json:"permission"`
}

type FolderGetResponsePayload

type FolderGetResponsePayload struct {
	Content FolderGetResponseContent `json:"content"`
}

type IDKeyCombo

type IDKeyCombo struct {
	ID  string `json:"id"`
	Key string `json:"key"`
}

type Key

type Key struct {
	FileID  int    `json:"file_id"`
	Type    string `json:"type"`
	ChatID  int    `json:"chat_id,string"`
	Key     string `json:"key"`
	IV      string `json:"iv"`
	ChatKey string `json:"chat_key"`
}

type KeyDerivationProperties

type KeyDerivationProperties struct {
	Iterations int    `json:"iterations"`
	Prf        string `json:"prf"`
	Salt       string `json:"salt"`
}

type Keys

type Keys struct {
	UserID     string `json:"user_id"`
	PrivateKey string `json:"private_key"`
	PublicKey  string `json:"public_Key"`
}

type LoginResponse

type LoginResponse struct {
	Status    Status               `json:"status"`
	Payload   LoginResponsePayload `json:"payload"`
	Signature string               `json:"signature"`
}

type LoginResponsePayload

type LoginResponsePayload struct {
	ClientKey string `json:"client_key"`
	UserInfo  User   `json:"userinfo"`
}

type ManageUser

type ManageUser struct {
	ID               string `json:"id"`
	FirstName        string `json:"first_name"`
	LastName         string `json:"last_name"`
	Tag              string `json:"tag"`
	Email            bool   `json:"email"`
	TimeJoined       string `json:"time_joined"`
	MembershipExpiry string `json:"membership_expiry,omitempty"`
	Deactivated      string `json:"deactivated,omitempty"`
	Active           string `json:"active,omitempty"`
	LastLogin        int    `json:"last_login,omitempty"`
	Image            string `json:"image,omitempty"`
	AllowsVoipCalls  bool   `json:"allows_voip_calls,omitempty"`
}

type ManageUsersListingResponse

type ManageUsersListingResponse struct {
	Status    Status                            `json:"status"`
	Payload   ManageUsersListingResponsePayload `json:"payload"`
	Signature string                            `json:"signature"`
}

type ManageUsersListingResponsePayload

type ManageUsersListingResponsePayload struct {
	TotalRecords int    `json:"num_total_records"`
	Users        []User `json:"users"`
}

type MembershipInfo

type MembershipInfo struct {
	IsMember     bool   `json:"is_member"`
	Joined       string `json:"joined"`
	Confirmation string `json:"confirmation"`
	MayManage    bool   `json:"may_manage"`
	Write        bool   `json:"write"`
}

type Message

type Message struct {
	ID             int    `json:"id"`
	Text           string `json:"text"`
	ConversationID int    `json:"conversation_id,omitempty"`
	ChannelID      int    `json:"channel_id,omitempty"`
	ThreadID       int    `json:"thread_id,omitempty"`
	Hash           string `json:"hash"`
	Verification   string `json:"verification"`
	Sender         User   `json:"sender"`
	IV             string `json:"iv"`
	Alarm          bool   `json:"alarm"`
	Kind           string `json:"kind"`
	Encrypted      bool   `json:"encrypted"`
	// SendTime is the unix timestamp for when the message was send
	// Depending on in what response this field is present it's either
	// encoded as a string (e.g. when requesting the contents of a channel)
	// or encoded as an integer (e.g. in the response to sending a message)
	SendTime    FlexInt `json:"time"`
	DeleteTime  int     `json:"deleted,string,omitempty"`
	IsForwarded bool    `json:"is_forwarded"`
	DeviceID    string  `json:"devicce_id"`
	Type        string  `json:"type"`
	ReplyTo     ReplyTo `json:"reply_to,omitempty"`
}

type MessageContentResponse

type MessageContentResponse struct {
	Status    Status                        `json:"status"`
	Payload   MessageContentResponsePayload `json:"payload"`
	Signature string                        `json:"signature"`
}

type MessageContentResponsePayload

type MessageContentResponsePayload struct {
	Messages []map[string]interface{} `json:"messages"`
}

type MessageResponse

type MessageResponse struct {
	Status    Status                 `json:"status"`
	Payload   MessageResponsePayload `json:"payload"`
	Signature string                 `json:"signature"`
}

type MessageResponsePayload

type MessageResponsePayload struct {
	Message Message `json:"message"`
}

type NestedKey

type NestedKey struct {
	Ciphertext string                  `json:"ciphertext"`
	IV         string                  `json:"iv"`
	KDP        KeyDerivationProperties `json:"key_derivation_properties"`
}

type PrivateKeyResponse

type PrivateKeyResponse struct {
	Status    Status                    `json:"status"`
	Payload   PrivateKeyResponsePayload `json:"payload"`
	Signature string                    `json:"signature"`
}

type PrivateKeyResponsePayload

type PrivateKeyResponsePayload struct {
	Keys Keys `json:"keys"`
}

type ReplyTo added in v0.3.1

type ReplyTo struct {
	MessageId           int    `json:"message_id,omitempty"`
	MessageHash         string `json:"message_hash,omitempty"`
	MessageVerification string `json:"message_verification,omitempty"`
}

func (*ReplyTo) UnmarshalJSON added in v0.3.1

func (rt *ReplyTo) UnmarshalJSON(b []byte) error

type Role

type Role struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Global    string `json:"global"`
	CompanyId string `json:"company_id"`
	Time      string `json:"time"`
}

type Status

type Status struct {
	Value        string          `json:"value"`
	ShortMessage json.RawMessage `json:"short_message"` // on some endpoints these are bool(false) instead of an empty string
	Message      json.RawMessage `json:"message"`
}

type StatusResponse

type StatusResponse struct {
	Status json.RawMessage `json:"status"`
}

type StatusTyped

type StatusTyped struct {
	Value        string `json:"value"`
	ShortMessage string `json:"short_message"`
	Message      string `json:"message"`
}

type SubscribedChannelsResponse

type SubscribedChannelsResponse struct {
	Status    Status                            `json:"status"`
	Payload   SubscribedChannelsResponsePayload `json:"payload"`
	Signature string                            `json:"signature"`
}

type SubscribedChannelsResponsePayload

type SubscribedChannelsResponsePayload struct {
	Channels []ChannelInfoIDString `json:"channels"`
}

type User

type User struct {
	ID              string `json:"id"`
	FirstName       string `json:"first_name"`
	LastName        string `json:"last_name"`
	SocketID        string `json:"socket_id,omitempty"`
	Online          bool   `json:"online"`
	Active          string `json:"active,omitempty"`
	Deleted         string `json:"deleted,omitempty"`
	AllowsVoipCalls bool   `json:"allows_voip_calls,omitempty"`
	Tag             string `json:"tag,omitempty"`
	PublicKey       string `json:"public_key"`
	Roles           []Role `json:"roles"`
}

type UserIDKeyCombination

type UserIDKeyCombination struct {
	UserID  string
	UserKey string
}

type UserInfoResponse

type UserInfoResponse struct {
	Status    Status                     `json:"status"`
	Payload   UserListingResponsePayload `json:"payload"`
	Signature string                     `json:"signature"`
}

type UserListingResponsePayload

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

type UsersListingResponse

type UsersListingResponse struct {
	Status    Status                      `json:"status"`
	Payload   UsersListingResponsePayload `json:"payload"`
	Signature string                      `json:"signature"`
}

type UsersListingResponsePayload

type UsersListingResponsePayload struct {
	Users []User `json:"users"`
}

Jump to

Keyboard shortcuts

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