model

package
v0.0.0-...-2b7f6e1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrAgentNotFound        = "agent not registered with this wasabee server"
	ErrEmptyAgent           = "empty agent request"
	ErrGetLinkUnpopulated   = "attempt to use GetLink on unpopulated *Operation"
	ErrGetMarkerUnpopulated = "attempt to use GetMarker on unpopulated *Operation"
	ErrInvalidOTT           = "invalid OneTimeToken"
	ErrKeyUnableToRemove    = "unable to remove key count for portal"
	ErrKeyUnableToRecord    = "unable to record keys, ensure the op on the server is up-to-date"
	ErrLinkNotFound         = "link not found"
	ErrMarkerNotFound       = "markernot found"
	ErrOpNotFound           = "operation not found"
	ErrMultipleIntelname    = "multiple intelname matches found, not using intelname results"
	ErrMultipleRocks        = "multiple rocks matches found, not using rocks results"
	ErrMultipleV            = "multiple V matches found, not using V results"
	ErrNameGenFailed        = "name generation failed"
	ErrNotOnTeamAddPerm     = "you must be on a team to add it as a permission"
	ErrNotOpOwner           = "not owner of op"
	ErrPortalNotFound       = "portal not found"
	ErrTaskNotFound         = "task not found"
	ErrUnknownGID           = "unknown GoogleID"
	ErrUnknownPermType      = "unknown permission type"
	ErrUnknownUser          = "unknown user"
)

These error values are error strings visible to users, they need to be migrated to the translation system

Variables

This section is empty.

Functions

func AddToChatMemberList

func AddToChatMemberList(agent TelegramID, chat TelegramID) error

AddToChatMemberList notes a telegramID has been seen in a given telegram chat

func ChatToTeam

func ChatToTeam(chat int64) (TeamID, OperationID, error)

ChatToTeam takes a chatID and returns a linked teamID

func Connect

func Connect(ctx context.Context, uri string) error

Connect tries to establish a connection to a MySQL/MariaDB database under the given URI and initializes the tables if they don"t exist yet.

func Disconnect

func Disconnect()

Disconnect closes the database connection called only at server shutdown

func DrawInsert

func DrawInsert(ctx context.Context, o *Operation, gid GoogleID) error

DrawInsert parses a raw op sent from the IITC plugin and stores it in the database use ONLY for initial op creation All assignment data and key count data is assumed to be correct

func DrawUpdate

func DrawUpdate(ctx context.Context, o *Operation, gid GoogleID) error

DrawUpdate is called to UPDATE an existing draw Links & Markers are added/removed as necessary -- assignments are properly updated as necessary (including notifications on change) Key count data is left untouched (unless the portal is no longer listed in the portals list). Database is locked per-op, each update runs in an all-or-nothing transaction

func FirebaseBroadcastList

func FirebaseBroadcastList() ([]string, error)

FirebaseBroadcastList returns all known firebase tokens for messaging all agents Firebase Multicast messages are limited to 500 tokens each, the caller must break the list up if necessary.

func GenerateSafeName

func GenerateSafeName() (string, error)

GenerateSafeName generates a slug (like GenerateName()) that doesn't exist in the database yet.

func IngressName

func IngressName(g messaging.GoogleID) string

IngressName is used for templates

func IsChatMember

func IsChatMember(agent TelegramID, chat TelegramID) bool

IsChatMember reports if a given telegramID has been seen in a given telegram chat

func LoadRevokedJWT

func LoadRevokedJWT() *util.Safemap

LoadRevokedJWT does nothing yet

func LocationClean

func LocationClean()

LocationClean is called from the background process to remove out-dated agent locations

func NewMarkerType

func NewMarkerType(old MarkerType) string

NewMarkerType is used to change from the old to the new marker type names

func RemoveFirebaseToken

func RemoveFirebaseToken(token string) error

RemoveFirebaseToken removes a given token from the database

func RemoveFromChatMemberList

func RemoveFromChatMemberList(agent TelegramID, chat TelegramID) error

RemoveFromChatMemberList removes the agent from the list for the telegram chat

func RocksToDB

func RocksToDB(a *RocksAgent) error

RocksToDB writes a rocks agent to the database

func StoreRevokedJWT

func StoreRevokedJWT(r *util.Safemap)

StoreRevokedJWT does nothing yet

func VTeamExists

func VTeamExists(vteam int64, vrole uint8, gid GoogleID) (bool, error)

VTeamExists checks if a v-team/role pair exists for a specific googleID

func VToDB

func VToDB(a *VAgent) error

VToDB updates the database to reflect an agent's current status at V.

Types

type AdOperation

type AdOperation struct {
	ID         OperationID
	Name       string
	IsOwner    bool
	Color      string
	TeamID     TeamID
	Modified   string
	LastEditID string
}

AdOperation is a sub-struct of Agent

type AdTeam

type AdTeam struct {
	ID            TeamID
	Name          string `json:"Name,omitempty"`
	RocksComm     string `json:"RocksComm,omitempty"`
	RocksKey      string `json:"RocksKey,omitempty"`
	JoinLinkToken string `json:"JoinLinkToken,omitempty"`
	ShareLoc      string `json:"State"`
	ShareWD       string
	LoadWD        string
	Owner         GoogleID
	VTeam         int64 `json:"VTeam,omitempty"`
	VTeamRole     uint8 `json:"VTeamRole,omitempty"`
}

AdTeam is a sub-struct of Agent

type Agent

type Agent struct {
	GoogleID      GoogleID     `json:"GoogleID"`
	Name          string       `json:"name,omitempty"`
	VName         string       `json:"vname,omitempty"`
	RocksName     string       `json:"rocksname,omitempty"`
	IntelName     string       `json:"intelname,omitempty"`
	CommunityName string       `json:"communityname,omitempty"`
	Level         uint8        `json:"level,omitempty"`  // from v
	OneTimeToken  OneTimeToken `json:"lockey,omitempty"` // historical name, is this used by any clients?
	VVerified     bool         `json:"Vverified,omitempty"`
	VBlacklisted  bool         `json:"blacklisted,omitempty"`
	EnlID         string       `json:"enlid,omitempty"` // clients use this to draw URLs to V profiles
	RocksVerified bool         `json:"rocks,omitempty"`
	RISC          bool         `json:"RISC,omitempty"`
	ProfileImage  string       `json:"pic,omitempty"`
	Teams         []AdTeam
	Ops           []AdOperation
	Telegram      struct {
		ID        int64  `json:"ID,omitempty"`
		Name      string `json:"name,omitempty"`
		Verified  bool   `json:"Verified,omitempty"`
		Authtoken string `json:"Authtoken,omitempty"`
	}
	IntelFaction string `json:"intelfaction,omitempty"`
	QueryToken   string `json:"querytoken,omitempty"`
	VAPIkey      string `json:"vapi,omitempty"`
	JWT          string `json:"jwt,omitempty"`
}

Agent is the complete agent struct, used for the /me page.

type AgentID

type AgentID interface {
	Gid() (GoogleID, error)
	fmt.Stringer
}

AgentID is anything that can be converted to a GoogleID or a string

type AgentLocation

type AgentLocation struct {
	Gid  GoogleID `json:"gid"`
	Lat  float64  `json:"lat"`
	Lon  float64  `json:"lng"`
	Date string   `json:"date"`
}

AgentLocation is the lite version used for the team location pull

type Attribute

type Attribute struct {
	ID    AttributeID `json:"ID"`
	Name  string      `json:"name"`
	Value string      `json:"value"`
}

Attribute is per-marker-type data

type AttributeID

type AttributeID string

AttributeID is the attribute ID

type DefensiveKey

type DefensiveKey struct {
	GID      GoogleID `json:"GID"`
	PortalID PortalID `json:"PortalID"`
	CapID    string   `json:"CapID"`
	Count    int32    `json:"Count"`
	Name     string   `json:"Name"`
	Lat      string   `json:"Lat"`
	Lon      string   `json:"Lng"`
}

DefensiveKey is a sub-struct of DefensiveKeyList

type DefensiveKeyList

type DefensiveKeyList struct {
	DefensiveKeys []DefensiveKey
	Fetched       string
}

DefensiveKeyList is the list of all defensive keys

type GoogleID

type GoogleID string

GoogleID is the primary location for interfacing with the agent type

func AppleIDtoGID

func AppleIDtoGID(id string) (GoogleID, error)

AppleIDtoGID returns a GoogleID for a given AppleID for now this is very dumb and doesn't try to do anything other than ensure the database doesn't throw an error if we want to manually map

func CommunityNameToGID

func CommunityNameToGID(name string) (GoogleID, error)

CommunityNameToGID takes a community name and returns a GoogleID

func GetGIDFromEnlID

func GetGIDFromEnlID(enlid string) (GoogleID, error)

GetGIDFromEnlID looks up an agent's GoogleID by V EnlID

func SearchAgentName

func SearchAgentName(agent string) (GoogleID, error)

SearchAgentName gets a GoogleID from an Agent's name, searching local name, V name (if known), Rocks name (if known) and telegram name (if known) returns "" on no match

func ToGid

func ToGid(in string) (GoogleID, error)

ToGid takes a string and returns a Gid for it -- for reasonable values of a string; it must look like a GoogleID otherwise it defaults to agent name

func (GoogleID) AgentInTeam

func (gid GoogleID) AgentInTeam(team TeamID) (bool, error)

AgentInTeam checks to see if a agent is in a team and enabled.

func (GoogleID) ClearCommunityName

func (gid GoogleID) ClearCommunityName() error

ClearCommunityName removes an agent's community name verification

func (GoogleID) Delete

func (gid GoogleID) Delete() error

Delete removes an agent and all associated data

func (GoogleID) FirebaseLocationTokens

func (gid GoogleID) FirebaseLocationTokens() ([]TeamToken, error)

FirebaserLocationTokens returns a list all tokens for the agents on the teams with which this agent is sharing location instead of sending to the team topics, we do the fanout manually -- to avoid hitting the (small) fanout quota

func (GoogleID) FirstLogin

func (gid GoogleID) FirstLogin() error

FirstLogin sets the required database records for a new agent

func (GoogleID) GetAgent

func (gid GoogleID) GetAgent() (*Agent, error)

GetAgent populates an Agent struct based on the gid

func (GoogleID) GetAgentLocations

func (gid GoogleID) GetAgentLocations() ([]AgentLocation, error)

GetAgentLocations is a fast-path to get all available agent locations

func (GoogleID) GetFirebaseTokens

func (gid GoogleID) GetFirebaseTokens() ([]string, error)

GetFirebaseTokens gets an agents FirebaseToken from the database

func (GoogleID) GetPicture

func (gid GoogleID) GetPicture() string

GetPicture returns the agent's Google Picture URL

func (GoogleID) GetVAPIkey

func (gid GoogleID) GetVAPIkey() (string, error)

GetVAPIkey (gid GoogleID) loads an agents's V API key (this should be unusual); "" is "not set"

func (GoogleID) Gid

func (gid GoogleID) Gid() (GoogleID, error)

Gid just satisfies the AgentID interface

func (GoogleID) IngressName

func (gid GoogleID) IngressName() (string, error)

IngressName returns an agent's name for a given GoogleID. returns err == sql.ErrNoRows if there is no such agent.

func (GoogleID) InsertDefensiveKey

func (gid GoogleID) InsertDefensiveKey(dk DefensiveKey) error

InsertDefensiveKey adds a new key to the list

func (GoogleID) IntelSmurf

func (gid GoogleID) IntelSmurf() bool

IntelSmurf checks to see if the agent has self-proclaimed to be a smurf (unset is OK)

func (GoogleID) ListDefensiveKeys

func (gid GoogleID) ListDefensiveKeys() (DefensiveKeyList, error)

ListDefensiveKeys gets all keys an agent is authorized to know about.

func (GoogleID) Lock

func (gid GoogleID) Lock(reason string) error

Lock disables an account -- called by RISC system

func (GoogleID) NewTeam

func (gid GoogleID) NewTeam(name string) (TeamID, error)

NewTeam initializes a new team and returns a teamID the creating gid is added and enabled on that team by default

func (GoogleID) OwnsTeam

func (gid GoogleID) OwnsTeam(teamID TeamID) (bool, error)

OwnsTeam returns true if the GoogleID owns the team identified by teamID

func (GoogleID) RISC

func (gid GoogleID) RISC() bool

RISC checks to see if the user was marked as compromised by Google

func (GoogleID) RemoveAllFirebaseTokens

func (gid GoogleID) RemoveAllFirebaseTokens() error

RemoveAllFirebaseTokens removes all tokens for a given agent

func (GoogleID) RemoveTelegramID

func (gid GoogleID) RemoveTelegramID() error

RemoveTelegramID clears any telegram configuration for a given agent

func (GoogleID) SetCommunityName

func (gid GoogleID) SetCommunityName(name string) error

SetCommunityName sets the name the agent is known as on the Niantic Community -- this is the most trustworthy source of agent identity

func (GoogleID) SetIntelData

func (gid GoogleID) SetIntelData(name, faction string) error

SetIntelData sets the untrusted data from IITC - do not depend on these values for authorization but if someone says they are a smurf, who are we to deny their self-identity?

func (GoogleID) SetLocation

func (gid GoogleID) SetLocation(lat, lon string) error

SetLocation updates the database to reflect a agent's current location

func (GoogleID) SetTeamState

func (gid GoogleID) SetTeamState(teamID TeamID, state bool) error

SetTeamState updates the agent's shareLoc the team

func (GoogleID) SetTelegramID

func (gid GoogleID) SetTelegramID(tgid TelegramID, name string) error

SetTelegramID adds a verified agent's telegram ID

func (GoogleID) SetVAPIkey

func (gid GoogleID) SetVAPIkey(key string) error

SetVAPIkey stores an agent's V API key (this should be unusual)

func (GoogleID) SetWDLoad

func (gid GoogleID) SetWDLoad(teamID TeamID, state bool) error

SetWDLoad updates the agent's desire to load WD keys from other agents on this team

func (GoogleID) SetWDShare

func (gid GoogleID) SetWDShare(teamID TeamID, state bool) error

SetWDShare updates the agent's willingness to share WD keys with other agents on this team

func (GoogleID) StoreFirebaseToken

func (gid GoogleID) StoreFirebaseToken(token string) error

StoreFirebaseToken adds a token in the database for an agent. gid is not unique, an agent may have any number of tokens (e.g. multiple devices/browsers). Pruning of dead tokens takes place in the senders upon error.

func (GoogleID) String

func (gid GoogleID) String() string

func (GoogleID) TeamListEnabled

func (gid GoogleID) TeamListEnabled() []TeamID

TeamListEnabled is used for getting a list of agent's enabled teams

func (GoogleID) TelegramID

func (gid GoogleID) TelegramID() (TelegramID, error)

TelegramID returns a telegram ID number for a gid

func (GoogleID) TelegramName

func (gid GoogleID) TelegramName() (string, error)

TelegramName returns a telegram friendly name for a gid

func (GoogleID) Unlock

func (gid GoogleID) Unlock(reason string) error

Unlock enables a disabled account -- called by RISC system

func (GoogleID) UpdatePicture

func (gid GoogleID) UpdatePicture(picurl string) error

UpdatePicture sets/updates the agent's google picture URL

func (GoogleID) Valid

func (gid GoogleID) Valid() bool

Valid returns "true" if the GoogleID is known to wasabee

type IntelFaction

type IntelFaction int8

IntelFaction is stored as an in in the database

func FactionFromString

func FactionFromString(in string) IntelFaction

FactionFromString takes a string and returns the int

func (IntelFaction) String

func (f IntelFaction) String() string

String returns the string representation of an IntelFaction

type KeyOnHand

type KeyOnHand struct {
	ID      PortalID `json:"portalId"`
	Gid     GoogleID `json:"gid"`
	Onhand  int32    `json:"onhand"`
	Capsule string   `json:"capsule"`
}

KeyOnHand describes the already in possession for the op

type Link struct {
	ID         LinkID   `json:"ID"`
	From       PortalID `json:"fromPortalId"`
	To         PortalID `json:"toPortalId"`
	Desc       string   `json:"description"`   // deprecated, use Comment from Task
	AssignedTo GoogleID `json:"assignedTo"`    // deprecated, use Assignments from Task
	ThrowOrder int16    `json:"throwOrderPos"` // deprecated, use Order from Task
	Completed  bool     `json:"completed"`     // deprecated, use State from Task
	Color      string   `json:"color"`
	MuCaptured int      `json:"mu"`
	Task
}

Link is the basic link data structure

func (*Link) SetColor

func (l *Link) SetColor(color string) error

SetColor changes the color of a link in an operation

func (*Link) Swap

func (l *Link) Swap() error

Swap changes the direction of a link in an operation

type LinkID

type LinkID string

LinkID wrapper to ensure type safety

func (LinkID) String

func (l LinkID) String() string

String returns the string version of a LinkID

type Marker

type Marker struct {
	ID         MarkerID    `json:"ID"`
	PortalID   PortalID    `json:"portalId"`
	Type       MarkerType  `json:"type"`
	AssignedTo GoogleID    `json:"assignedTo,omitempty"` // deprecated, use Assignments from Task
	Attributes []Attribute `json:"attributes,omitempty"`
	Task
}

Marker is defined by the Wasabee IITC plugin.

type MarkerID

type MarkerID string

MarkerID wrapper to ensure type safety

func (MarkerID) String

func (m MarkerID) String() string

String returns the string version of a MarkerID

type MarkerType

type MarkerType string

MarkerType will be an enum once we figure out the full list

func (MarkerType) String

func (m MarkerType) String() string

String returns the string version of a PortalID

type OneTimeToken

type OneTimeToken string

OneTimeToken - used to authenticate users in IITC when GAPI doesn't work for them

func (OneTimeToken) Gid

func (ott OneTimeToken) Gid() (GoogleID, error)

Gid converts a location share key to a agent's gid

func (OneTimeToken) Increment

func (ott OneTimeToken) Increment() (GoogleID, error)

Increment "uses" the OTT and returns a googleID, replacing the agent's OTT in the databse

func (OneTimeToken) String

func (ott OneTimeToken) String() string

String is a stringer for OTT

type OpPermRole

type OpPermRole string

OpPermRole is just a convenience class for the permission string

func (OpPermRole) Valid

func (perm OpPermRole) Valid() bool

Valid checks to make sure the OpPermRole is one of the valid options

type OpPermission

type OpPermission struct {
	OpID   OperationID `json:"opid"`
	TeamID TeamID      `json:"teamid"`
	Role   OpPermRole  `json:"role"`
	Zone   Zone        `json:"zone"`
}

OpPermission is the form of permission

type OpStat

type OpStat struct {
	ID         OperationID `json:"ID"`
	Name       string      `json:"name"`
	Gid        GoogleID    `json:"creator"`
	Modified   string      `json:"modified"` // time.RFC1123 format
	LastEditID string      `json:"lasteditid"`
}

OpStat is a minimal struct to determine if the op has been updated

type Operation

type Operation struct {
	ID        OperationID `json:"ID"`      // 40-char string
	Name      string      `json:"name"`    // freeform
	Gid       GoogleID    `json:"creator"` // IITC plugin sends agent name on first upload, we convert to GID
	Color     string      `json:"color"`   // now free-form
	OpPortals []Portal    `json:"opportals"`
	Anchors   []PortalID  `json:"anchors"` // We should let the clients build this themselves
	Links     []Link      `json:"links"`
	// Blockers   []Link            `json:"blockers"` // ignored by Wasabee-Server -- do not store this
	Markers       []Marker          `json:"markers"`
	Teams         []OpPermission    `json:"teamlist"`
	Modified      string            `json:"modified"`      // time.RFC1123 format
	LastEditID    string            `json:"lasteditid"`    // 40-char string, generated by Touch()
	ReferenceTime string            `json:"referencetime"` // time.RFC1123 format
	Comment       string            `json:"comment"`
	Keys          []KeyOnHand       `json:"keysonhand"`
	Fetched       string            `json:"fetched"` // time.RFC1123 format
	Zones         []ZoneListElement `json:"zones"`
}

Operation is defined by the Wasabee IITC plugin. It is the top level item in the JSON file.

func (*Operation) AssignedOnlyAccess

func (o *Operation) AssignedOnlyAccess(gid GoogleID) bool

AssignedOnlyAccess verifies if an agent has AO access to an op

func (*Operation) Delete

func (o *Operation) Delete(gid GoogleID) error

Delete removes an operation and all associated data

func (o *Operation) GetLink(linkID LinkID) (*Link, error)

GetLink looks up and returns a populated Link from an id

func (*Operation) GetMarker

func (o *Operation) GetMarker(markerID MarkerID) (*Marker, error)

GetMarker lookup and return a populated Marker from an id

func (*Operation) GetTask

func (o *Operation) GetTask(taskID TaskID) (*Task, error)

GetTask looks up and returns a populated Task from an id

func (*Operation) GetTaskByStepNumber

func (o *Operation) GetTaskByStepNumber(step int16) (UnspecifiedTask, error)

GetTaskByStepNumber returns a task based on it's operation position if multiple tasks share one step number, the results are non-deterministic

func (*Operation) KeyOnHand

func (o *Operation) KeyOnHand(gid GoogleID, portalID PortalID, count int32, capsule string) error

KeyOnHand updates a user's key-count for linking

func (*Operation) LinkOrder

func (o *Operation) LinkOrder(order string) error

LinkOrder changes the order of the throws for an operation

func (*Operation) MarkerOrder

func (o *Operation) MarkerOrder(order string) error

MarkerOrder changes the order of the tasks for an operation

func (*Operation) Populate

func (o *Operation) Populate(gid GoogleID) error

Populate takes a pointer to an Operation and fills it in; o.ID must be set checks to see that either the gid created the operation or the gid is on the team assigned to the operation

func (*Operation) PopulateTeams

func (o *Operation) PopulateTeams() error

PopulateTeams loads the permissions from the database into the op data

func (*Operation) PortalDetails

func (o *Operation) PortalDetails(portalID PortalID, gid GoogleID) (*Portal, error)

PortalDetails returns information about the portal does access checking (cached)

func (*Operation) ReadAccess

func (o *Operation) ReadAccess(gid GoogleID) (bool, []Zone)

ReadAccess determines if an agent has read acces to an op, if zone limitations are present, return those as well

func (*Operation) SetInfo

func (o *Operation) SetInfo(info string, gid GoogleID) error

SetInfo changes the description of an operation

func (*Operation) Touch

func (o *Operation) Touch() (string, error)

Touch updates the modified timestamp on an operation

func (*Operation) WriteAccess

func (o *Operation) WriteAccess(gid GoogleID) bool

WriteAccess determines if an agent has write access to an op

type OperationID

type OperationID string

OperationID wrapper to ensure type safety

func (OperationID) AddPerm

func (opID OperationID) AddPerm(gid GoogleID, teamID TeamID, perm string, zone Zone) error

AddPerm adds a new permission to an op

func (OperationID) Chown

func (opID OperationID) Chown(gid GoogleID, to string) error

Chown changes an operation's owner

func (OperationID) DelPerm

func (opID OperationID) DelPerm(gid GoogleID, teamID TeamID, perm OpPermRole, zone Zone) error

DelPerm removes a permission from an op

func (OperationID) IsDeletedOp

func (opID OperationID) IsDeletedOp() bool

IsDeletedOp reports back if a particular op has been deleted

func (OperationID) IsOwner

func (opID OperationID) IsOwner(gid GoogleID) bool

IsOwner returns a bool value determining if the operation is owned by the specified googleID

func (OperationID) PortalComment

func (opID OperationID) PortalComment(portalID PortalID, comment string) error

PortalComment updates the comment on a portal

func (OperationID) PortalHardness

func (opID OperationID) PortalHardness(portalID PortalID, hardness string) error

PortalHardness updates the comment on a portal

func (OperationID) Rename

func (opID OperationID) Rename(gid GoogleID, name string) error

Rename changes an op's name

func (OperationID) Stat

func (opID OperationID) Stat() (*OpStat, error)

Stat returns useful info on an operation

func (OperationID) Teams

func (opID OperationID) Teams() ([]TeamID, error)

Teams returns a list of every team with access to this operation

func (OperationID) Valid

func (opID OperationID) Valid() bool

type Portal

type Portal struct {
	ID       PortalID `json:"id"`
	Name     string   `json:"name"`
	Lat      string   `json:"lat"` // passing these as strings saves me parsing them
	Lon      string   `json:"lng"`
	Comment  string   `json:"comment"`
	Hardness string   `json:"hardness"` // string for now, enum in the future
	// contains filtered or unexported fields
}

Portal is defined by the Wasabee IITC plugin.

type PortalID

type PortalID string

PortalID wrapper to ensure type safety

func (PortalID) String

func (p PortalID) String() string

String returns the string version of a PortalID

type RocksAgent

type RocksAgent struct {
	Gid      GoogleID `json:"gid"`
	TGId     int64    `json:"tgid"`
	Agent    string   `json:"agentid"`
	Verified bool     `json:"verified"`
	Smurf    bool     `json:"smurf"`
}

RocksAgent is defined by enlightened.rocks

func RocksFromDB

func RocksFromDB(gid GoogleID) (*RocksAgent, time.Time, error)

RocksFromDB returns a rocks agent from the database

type Task

type Task struct {
	ID           TaskID     `json:"task"`
	Assignments  []GoogleID `json:"assignments"`
	DependsOn    []TaskID   `json:"dependsOn"`
	Zone         Zone       `json:"zone"`
	DeltaMinutes int32      `json:"deltaminutes"`
	State        string     `json:"state"`
	Comment      string     `json:"comment"`
	Order        int16      `json:"order"`
	// contains filtered or unexported fields
}

Task is the imported things for markers and links

func (*Task) Acknowledge

func (t *Task) Acknowledge() error

Acknowledge marks a task as acknowledged

func (*Task) AddDepend

func (t *Task) AddDepend(task TaskID) error

AddDepend add a single task dependency

func (*Task) Claim

func (t *Task) Claim(gid GoogleID) error

Claim assignes a task to the calling agent

func (*Task) ClearAssignments

func (t *Task) ClearAssignments(tx *sql.Tx) error

ClearAssignments removes any assignments for this task from the database

func (*Task) Complete

func (t *Task) Complete() error

Complete marks as task as completed

func (*Task) DelDepend

func (t *Task) DelDepend(task TaskID) error

DelDepend deletes all dependencies for a task

func (*Task) GetAssignments

func (t *Task) GetAssignments(tx *sql.Tx) ([]GoogleID, error)

GetAssignments gets all assignments for a task

func (*Task) GetOrder

func (t *Task) GetOrder() int16

GetOrder returns a tasks order

func (*Task) Incomplete

func (t *Task) Incomplete() error

Incomplete marks a task as not completed

func (*Task) IsAssignedTo

func (t *Task) IsAssignedTo(gid GoogleID) bool

IsAssignedTo checks to see if a task is assigned to a particular agent

func (*Task) Reject

func (t *Task) Reject(gid GoogleID) error

Reject unassignes an agent from a task

func (*Task) SetAssignments

func (t *Task) SetAssignments(gs []GoogleID, tx *sql.Tx) error

SetAssignments assigns a task to an agent using a given transaction, if the transaction is nil, one is created for this block

func (*Task) SetComment

func (t *Task) SetComment(comment string) error

SetComment sets the comment on a task

func (*Task) SetDelta

func (t *Task) SetDelta(delta int) error

SetDelta sets the DeltaMinutes of a link in an operation

func (*Task) SetDepends

func (t *Task) SetDepends(d []TaskID, tx *sql.Tx) error

SetDepends overwrites a task's dependencies, if tx is null, one is created

func (*Task) SetOrder

func (t *Task) SetOrder(order int16) error

SetOrder updates the task'sorder

func (*Task) SetZone

func (t *Task) SetZone(z Zone) error

SetZone updates the task's zone

type TaskID

type TaskID string

TaskID is the basic type for a task identifier

type TeamData

type TeamData struct {
	Name          string       `json:"name"`
	ID            TeamID       `json:"id"`
	TeamMembers   []TeamMember `json:"agents"`
	RocksComm     string       `json:"rc,omitempty"`
	RocksKey      string       `json:"rk,omitempty"`
	JoinLinkToken string       `json:"jlt,omitempty"`
	VTeam         int64        `json:"vt,omitempty"`
	VRole         int8         `json:"vr,omitempty"`
}

TeamData is the wrapper type containing all the team info

type TeamID

type TeamID string

TeamID is the primary means for interfacing with teams

func GetAllTeams

func GetAllTeams() ([]TeamID, error)

func GetTeamsByVID

func GetTeamsByVID(v int64) ([]TeamID, error)

GetTeamsByVID returns all wasabee teams which match the V team ID

func RocksCommunityToTeam

func RocksCommunityToTeam(communityID string) (TeamID, error)

RocksCommunityToTeam returns a TeamID from a Rocks Community

func (TeamID) AddAgent

func (teamID TeamID) AddAgent(in AgentID) error

AddAgent adds a agent to a team

func (TeamID) Chown

func (teamID TeamID) Chown(to AgentID) error

Chown changes a team's ownership caller must verify permissions

func (TeamID) Delete

func (teamID TeamID) Delete() error

Delete removes the team identified by teamID does not check team ownership -- caller should take care of authorization

func (TeamID) DeleteJoinToken

func (teamID TeamID) DeleteJoinToken() error

DeleteJoinToken removes a team's join link token

func (TeamID) FetchFBTokens

func (teamID TeamID) FetchFBTokens() ([]string, error)

func (TeamID) FetchTeam

func (teamID TeamID) FetchTeam() (*TeamData, error)

FetchTeam populates an entire TeamData struct

func (TeamID) GenerateJoinToken

func (teamID TeamID) GenerateJoinToken() (string, error)

GenerateJoinToken sets a team's join link token

func (TeamID) JoinToken

func (teamID TeamID) JoinToken(gid GoogleID, key string) error

JoinToken verifies a join link

func (TeamID) LinkToTelegramChat

func (teamID TeamID) LinkToTelegramChat(chat TelegramID, opID OperationID) error

LinkToTelegramChat associates a telegram chat ID with the team, performs authorization a chat can be linked to a single team a team can be linked to a single chat (irrespective of opID)

func (TeamID) Name

func (teamID TeamID) Name() (string, error)

Name returns a team's friendly name for a TeamID

func (TeamID) Operations

func (teamID TeamID) Operations() ([]OpPermission, error)

Operations returns a slice containing all the OpPermissions which reference this team

func (TeamID) Owner

func (teamID TeamID) Owner() (GoogleID, error)

Owner returns the owner of the team

func (TeamID) RemoveAgent

func (teamID TeamID) RemoveAgent(in AgentID) error

RemoveAgent removes a agent (identified by location share key, GoogleID, agent name, or EnlID) from a team.

func (TeamID) Rename

func (teamID TeamID) Rename(name string) error

Rename sets a new name for a teamID does not check team ownership -- caller should take care of authorization

func (TeamID) RocksCommunity

func (teamID TeamID) RocksCommunity() (string, error)

RocksCommunity returns a communityID for a TeamID

func (TeamID) RocksKey

func (teamID TeamID) RocksKey() (string, error)

RocksKey returns a rocks key for a TeamID

func (TeamID) SetComment

func (teamID TeamID) SetComment(gid GoogleID, comment string) error

SetComment sets an agent's comment on a given team

func (TeamID) SetRocks

func (teamID TeamID) SetRocks(key, community string) error

SetRocks links a team to a community at enl.rocks. Does not check team ownership -- caller should take care of authorization. Local adds/deletes will be pushed to the community (API management must be enabled on the community at enl.rocks). adds/deletes at enl.rocks will be pushed here (onJoin/onLeave web hooks must be configured in the community at enl.rocks)

func (TeamID) String

func (teamID TeamID) String() string

func (TeamID) TelegramChat

func (teamID TeamID) TelegramChat() (int64, error)

TelegramChat returns the associated telegram chat ID for this team, if any

func (TeamID) UnlinkFromTelegramChat

func (teamID TeamID) UnlinkFromTelegramChat() error

UnlinkFromTelegramChat disassociates a telegram chat ID from the team -- not authenticated since bot removal from chat is enough

func (TeamID) VConfigure

func (teamID TeamID) VConfigure(vteam int64, role uint8) error

VConfigure sets V connection for a Wasabee team -- caller should verify ownership

func (TeamID) VTeam

func (teamID TeamID) VTeam() (int64, uint8, error)

VTeam returns the V team/role pair for a Wasabee team

func (TeamID) Valid

func (teamID TeamID) Valid() bool

Valid checks to see if team exists.

type TeamMember

type TeamMember struct {
	Gid           GoogleID `json:"id"`
	Name          string   `json:"name"`
	VName         string   `json:"vname,omitempty"`
	RocksName     string   `json:"rocksname,omitempty"`
	IntelName     string   `json:"intelname,omitempty"`
	CommunityName string   `json:"communityname,omitempty"`
	Level         uint8    `json:"level,omitempty"`
	EnlID         string   `json:"enlid,omitempty"`
	PictureURL    string   `json:"pic,omitempty"`
	Verified      bool     `json:"Vverified"`
	Blacklisted   bool     `json:"blacklisted"`
	RocksVerified bool     `json:"rocks"`
	RocksSmurf    bool     `json:"smurf"`
	IntelFaction  string   `json:"intelfaction"`
	Comment       string   `json:"squad,omitempty"`
	ShareLocation bool     `json:"state"`
	Lat           float64  `json:"lat,omitempty"`
	Lon           float64  `json:"lng,omitempty"`
	Date          string   `json:"date"`
	ShareWD       bool     `json:"shareWD"`
	LoadWD        bool     `json:"loadWD"`
}

TeamMember is the light version of AgentData, containing visible information exported to teams

func FetchAgent

func FetchAgent(id AgentID, caller GoogleID) (*TeamMember, error)

FetchAgent populates the minimal Agent struct with data anyone can see

type TeamToken

type TeamToken struct {
	TeamID TeamID
	Token  string
}

TeamToken is the returned struct from FirebaseLocationTokens

type TelegramID

type TelegramID int64

TelegramID is a user ID from telegram

func GetAllTelegramIDs

func GetAllTelegramIDs() ([]TelegramID, error)

GetAllTelegramIDs is used by the telegram cleanup function

func (TelegramID) Delete

func (tgid TelegramID) Delete() error

Delete is used to remove a TelegramID

func (TelegramID) Gid

func (tgid TelegramID) Gid() (GoogleID, error)

Gid returns a verified GoogleID for a Telegram ID

func (TelegramID) GidV

func (tgid TelegramID) GidV() (GoogleID, bool, error)

GidV returns a googleID/verified pair for a given telegram ID

func (TelegramID) InitAgent

func (tgid TelegramID) InitAgent(name string, ott OneTimeToken) error

InitAgent establishes a new telegram user in the database and begins the verification process

func (TelegramID) SetName

func (tgid TelegramID) SetName(name string) error

SetName is used to set an agent's telegram display name

func (TelegramID) String

func (tgid TelegramID) String() string

String returns a string format of a TelegramID

func (TelegramID) UnverifyAgent

func (tgid TelegramID) UnverifyAgent() error

UnverifyAgent marks an ID as unverified (if the agent blocks the bot)

func (TelegramID) VerifyAgent

func (tgid TelegramID) VerifyAgent(authtoken string) error

VerifyAgent is the second stage of the verication process

type UnspecifiedTask

type UnspecifiedTask interface {
	Claim(GoogleID) error
	Reject(GoogleID) error
	SetOrder(int16) error
	GetOrder() int16
	IsAssignedTo(GoogleID) bool
	Acknowledge() error
}

UnspecifiedTask is the type for tasks which could be either markers or links

type VAgent

type VAgent struct {
	EnlID       string   `json:"enlid"`
	Gid         GoogleID `json:"gid"`
	Vlevel      int64    `json:"vlevel"`
	Vpoints     int64    `json:"vpoints"`
	Agent       string   `json:"agent"`
	Level       int64    `json:"level"`
	Quarantine  bool     `json:"quarantine"`
	Active      bool     `json:"active"`
	Blacklisted bool     `json:"blacklisted"`
	Verified    bool     `json:"verified"`
	Flagged     bool     `json:"flagged"`
	Banned      bool     `json:"banned_by_nia"`
	CellID      string   `json:"cellid"`
	TelegramID  int64    `json:"telegramid"`
	Telegram    string   `json:"telegram"`
	Email       string   `json:"email"`
	StartLat    float64  `json:"lat"`
	StartLon    float64  `json:"lon"`
	Distance    int64    `json:"distance"`
	Roles       []struct {
		ID   uint8  `json:"id"`
		Name string `json:"name"`
	} `json:"roles"`
}

VAgent is set by the V API most of these fields are empty unless filled in by a team query

func VFromDB

func VFromDB(gid GoogleID) (*VAgent, time.Time, error)

VFromDB pulls a V agent from the database

type Zone

type Zone int

Zone is the sub-operation zone identifer

const (
	ZoneAssignOnly Zone = -1
	ZoneAll        Zone = 0
)

ZoneAll is a reserved name for the wildcard zone

func ZoneFromString

func ZoneFromString(in string) Zone

ZoneFromString takes a string and returns a valid zone or zonePrimary if invalid input

func (Zone) Valid

func (z Zone) Valid() bool

Valid returns a boolean if the zone is in the valid range

type ZoneListElement

type ZoneListElement struct {
	Zone   Zone        `json:"id"`
	Name   string      `json:"name"`
	Points []zonepoint `json:"points"` // just a string for the client to parse
	Color  string      `json:"color"`
}

ZoneListElement is used to map display names to zones

Jump to

Keyboard shortcuts

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