utils

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2016 License: BSD-3-Clause, BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReaderSep is the string that separates readers from writers in a
	// TLF name.
	ReaderSep = "#"

	// TlfHandleExtensionSep is the string that separates the folder
	// participants from an extension suffix in the TLF name.
	TlfHandleExtensionSep = " "

	// PublicUIDName is the name given to keybase1.PublicUID.  This string
	// should correspond to an illegal or reserved Keybase user name.
	PublicUIDName = "_public"
)

Variables

This section is empty.

Functions

func AggRateLimits

func AggRateLimits(rlimits []chat1.RateLimit) (res []chat1.RateLimit)

func AggRateLimitsP

func AggRateLimitsP(rlimits []*chat1.RateLimit) (res []chat1.RateLimit)

AggRateLimitsP takes a list of rate limit responses and dedups them to the last one received of each category

func Collar

func Collar(lower int, ideal int, upper int) int

upper bounds takes higher priority

func FilterByType

func FilterByType(msgs []chat1.MessageUnboxed, query *chat1.GetThreadQuery) (res []chat1.MessageUnboxed)

func ParseDurationExtended

func ParseDurationExtended(s string) (d time.Duration, err error)

parseDurationExtended is like time.ParseDuration, but adds "d" unit. "1d" is one day, defined as 24*time.Hour. Only whole days are supported for "d" unit, but it can be followed by smaller units, e.g., "1d1h".

func ParseTimeFromRFC3339OrDurationFromPast

func ParseTimeFromRFC3339OrDurationFromPast(kbCtx KeybaseContext, s string) (t time.Time, err error)

func ReorderParticipants

func ReorderParticipants(udc *UserDeviceCache, uimap *UserInfoMapper, tlfname string, activeList []gregor1.UID) (writerNames []string, readerNames []string, err error)

Reorder participants based on the order in activeList. Only allows usernames from tlfname in the output. This never fails, worse comes to worst it just returns the split of tlfname.

Types

type BadTLFNameError

type BadTLFNameError struct {
	Name string
}

BadTLFNameError indicates a top-level folder name that has an incorrect format.

func (BadTLFNameError) Error

func (e BadTLFNameError) Error() string

Error implements the error interface for BadTLFNameError.

type KeybaseContext

type KeybaseContext interface {
	GetLog() logger.Logger
	LoadUserByUID(uid keybase1.UID) (*libkb.User, error)
	Clock() clockwork.Clock
}

KeybaseContext defines what chat needs from Keybase

type NoSuchNameError

type NoSuchNameError struct {
	Name string
}

NoSuchNameError indicates that the user tried to access a subdirectory entry that doesn't exist.

func (NoSuchNameError) Error

func (e NoSuchNameError) Error() string

Error implements the error interface for NoSuchNameError

type NoSuchUserError

type NoSuchUserError struct {
	Input string
}

NoSuchUserError indicates that the given user couldn't be resolved.

func (NoSuchUserError) Error

func (e NoSuchUserError) Error() string

Error implements the error interface for NoSuchUserError

func (NoSuchUserError) ToStatus

func (e NoSuchUserError) ToStatus() keybase1.Status

ToStatus implements the keybase1.ToStatusAble interface for NoSuchUserError

type TlfNameNotCanonical

type TlfNameNotCanonical struct {
	Name, NameToTry string
}

TlfNameNotCanonical indicates that a name isn't a canonical, and that another (not necessarily canonical) name should be tried.

func (TlfNameNotCanonical) Error

func (e TlfNameNotCanonical) Error() string

type UserDeviceCache

type UserDeviceCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

UserDeviceCache looks up usernames and device names, memoizing the results. These bindings are immutable and can be cached forever.

func NewUserDeviceCache

func NewUserDeviceCache(kbCtx KeybaseContext) *UserDeviceCache

func (*UserDeviceCache) LookupUsername

func (c *UserDeviceCache) LookupUsername(uimap *UserInfoMapper, uid keybase1.UID) (username string, err error)

func (*UserDeviceCache) LookupUsernameAndDeviceName

func (c *UserDeviceCache) LookupUsernameAndDeviceName(uimap *UserInfoMapper, uid keybase1.UID, deviceID keybase1.DeviceID) (username string, devicename string, err error)

type UserInfoMapper

type UserInfoMapper struct {
	sync.Mutex
	// contains filtered or unexported fields
}

UserInfoMapper looks up usernames and device names, memoizing the results. Only intended to be used for a single request (i.e., getting all the users and devices for a thread).

func GetUserInfoMapper

func GetUserInfoMapper(ctx context.Context, kbCtx KeybaseContext) (context.Context, *UserInfoMapper)

func (*UserInfoMapper) Lookup

func (u *UserInfoMapper) Lookup(uid keybase1.UID, deviceID keybase1.DeviceID) (username, deviceName string, err error)

func (*UserInfoMapper) User

func (u *UserInfoMapper) User(uid keybase1.UID) (*libkb.User, error)

Jump to

Keyboard shortcuts

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