utils

package
v1.0.30 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2017 License: BSD-3-Clause, BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatTopicIDLen    = 16
	ChatTopicIDSuffix = 0x20
)

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 AllChatConversationStatuses added in v1.0.19

func AllChatConversationStatuses() (res []chat1.ConversationStatus)

func Collar

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

upper bounds takes higher priority

func CreateTopicNameState added in v1.0.27

func CreateTopicNameState(cmp chat1.ConversationIDMessageIDPairs) (chat1.TopicNameState, error)

func DecodeBase64 added in v1.0.29

func DecodeBase64(enc []byte) ([]byte, error)

func DecodePagination added in v1.0.29

func DecodePagination(p *chat1.UIPagination) (res *chat1.Pagination, err error)

func FilterByType

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

FilterByType filters messages based on a query. If includeAllErrors then MessageUnboxedError are all returned. Otherwise, they are filtered based on type. Messages whose type cannot be determined are considered errors.

func GetConvMtime added in v1.0.28

func GetConvMtime(conv chat1.Conversation) gregor1.Time

func GetConvMtimeLocal added in v1.0.28

func GetConvMtimeLocal(conv chat1.ConversationLocal) gregor1.Time

func GetConvSnippet added in v1.0.28

func GetConvSnippet(conv chat1.ConversationLocal) string

func GetHeadline added in v1.0.29

func GetHeadline(conv chat1.ConversationLocal) string

func GetSupersedes added in v1.0.19

func GetSupersedes(msg chat1.MessageUnboxed) ([]chat1.MessageID, error)

GetSupersedes must be called with a valid msg

func GetTopicName added in v1.0.27

func GetTopicName(conv chat1.ConversationLocal) string

func IsConvEmpty added in v1.0.21

func IsConvEmpty(conv chat1.Conversation) bool

func IsVisibleChatMessageType added in v1.0.19

func IsVisibleChatMessageType(messageType chat1.MessageType) bool

func NewChatTopicID added in v1.0.19

func NewChatTopicID() (id []byte, err error)

func NotificationInfoSet added in v1.0.27

func NotificationInfoSet(settings *chat1.ConversationNotificationInfo,
	apptype keybase1.DeviceType,
	kind chat1.NotificationKind, enabled bool)

func ParseAndDecorateAtMentionedUIDs added in v1.0.27

func ParseAndDecorateAtMentionedUIDs(ctx context.Context, body string, upak libkb.UPAKLoader, debug *DebugLabeler) (newBody string, atRes []gregor1.UID, chanRes chat1.ChannelMention)

func ParseAtMentionedUIDs added in v1.0.27

func ParseAtMentionedUIDs(ctx context.Context, body string, upak libkb.UPAKLoader, debug *DebugLabeler) (atRes []gregor1.UID, chanRes chat1.ChannelMention)

func ParseAtMentionsNames added in v1.0.27

func ParseAtMentionsNames(ctx context.Context, body string) (res []string)

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(g *globals.Context, s string) (t time.Time, err error)

func PickLatestMessageUnboxed added in v1.0.28

func PickLatestMessageUnboxed(conv chat1.ConversationLocal, typs []chat1.MessageType) (res chat1.MessageUnboxed, err error)

func PluckConvIDs added in v1.0.27

func PluckConvIDs(convs []chat1.Conversation) (res []chat1.ConversationID)

func PluckConvIDsLocal added in v1.0.27

func PluckConvIDsLocal(convs []chat1.ConversationLocal) (res []chat1.ConversationID)

func PluckMessageIDs added in v1.0.21

func PluckMessageIDs(msgs []chat1.MessageSummary) []chat1.MessageID

func PresentConversationLocal added in v1.0.28

func PresentConversationLocal(rawConv chat1.ConversationLocal) (res chat1.InboxUIItem)

func PresentConversationLocals added in v1.0.29

func PresentConversationLocals(convs []chat1.ConversationLocal) (res []chat1.InboxUIItem)

func PresentMessageUnboxed added in v1.0.29

func PresentMessageUnboxed(rawMsg chat1.MessageUnboxed) (res chat1.UIMessage)

func PresentPagination added in v1.0.29

func PresentPagination(p *chat1.Pagination) (res *chat1.UIPagination)

func ReorderParticipants

func ReorderParticipants(ctx context.Context, uloader ReorderUsernameSource, 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.

func SanitizeTopicName added in v1.0.27

func SanitizeTopicName(topicName string) string

func VisibleChatConversationStatuses added in v1.0.19

func VisibleChatConversationStatuses() (res []chat1.ConversationStatus)

Which convs show in the inbox.

func VisibleChatMessageTypes added in v1.0.19

func VisibleChatMessageTypes() []chat1.MessageType

Types

type ByConvID added in v1.0.27

type ByConvID []chat1.ConversationID

func (ByConvID) Len added in v1.0.27

func (c ByConvID) Len() int

func (ByConvID) Less added in v1.0.27

func (c ByConvID) Less(i, j int) bool

func (ByConvID) Swap added in v1.0.27

func (c ByConvID) Swap(i, j int)

type ByMsgSummaryCtime added in v1.0.28

type ByMsgSummaryCtime []chat1.MessageSummary

func (ByMsgSummaryCtime) Len added in v1.0.28

func (c ByMsgSummaryCtime) Len() int

func (ByMsgSummaryCtime) Less added in v1.0.28

func (c ByMsgSummaryCtime) Less(i, j int) bool

func (ByMsgSummaryCtime) Swap added in v1.0.28

func (c ByMsgSummaryCtime) Swap(i, j int)

type ByMsgUnboxedCtime added in v1.0.28

type ByMsgUnboxedCtime []chat1.MessageUnboxed

func (ByMsgUnboxedCtime) Len added in v1.0.28

func (c ByMsgUnboxedCtime) Len() int

func (ByMsgUnboxedCtime) Less added in v1.0.28

func (c ByMsgUnboxedCtime) Less(i, j int) bool

func (ByMsgUnboxedCtime) Swap added in v1.0.28

func (c ByMsgUnboxedCtime) Swap(i, j int)

type ConvByConvID added in v1.0.27

type ConvByConvID []chat1.Conversation

func (ConvByConvID) Len added in v1.0.27

func (c ConvByConvID) Len() int

func (ConvByConvID) Less added in v1.0.27

func (c ConvByConvID) Less(i, j int) bool

func (ConvByConvID) Swap added in v1.0.27

func (c ConvByConvID) Swap(i, j int)

type ConvLocalByConvID added in v1.0.27

type ConvLocalByConvID []chat1.ConversationLocal

func (ConvLocalByConvID) Len added in v1.0.27

func (c ConvLocalByConvID) Len() int

func (ConvLocalByConvID) Less added in v1.0.27

func (c ConvLocalByConvID) Less(i, j int) bool

func (ConvLocalByConvID) Swap added in v1.0.27

func (c ConvLocalByConvID) Swap(i, j int)

type ConvLocalByTopicName added in v1.0.27

type ConvLocalByTopicName []chat1.ConversationLocal

func (ConvLocalByTopicName) Len added in v1.0.27

func (c ConvLocalByTopicName) Len() int

func (ConvLocalByTopicName) Less added in v1.0.27

func (c ConvLocalByTopicName) Less(i, j int) bool

func (ConvLocalByTopicName) Swap added in v1.0.27

func (c ConvLocalByTopicName) Swap(i, j int)

type ConversationStatusBehavior added in v1.0.19

type ConversationStatusBehavior struct {
	// Whether to show the conv in the inbox
	ShowInInbox bool
	// Whether sending to this conv sets it back to UNFILED
	SendingRemovesStatus bool
	// Whether any incoming activity sets it back to UNFILED
	ActivityRemovesStatus bool
	// Whether to show desktop notifications
	DesktopNotifications bool
	// Whether to send push notifications
	PushNotifications bool
	// Whether to show as part of badging
	ShowBadges bool
}

ConversationStatusBehavior describes how a ConversationStatus behaves

func GetConversationStatusBehavior added in v1.0.19

func GetConversationStatusBehavior(s chat1.ConversationStatus) ConversationStatusBehavior

GetConversationStatusBehavior gives information about what is allowed for a conversation status. When changing these, be sure to update gregor's postMessage as well

type DebugLabeler added in v1.0.19

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

func NewDebugLabeler added in v1.0.19

func NewDebugLabeler(log logger.Logger, label string, verbose bool) DebugLabeler

func (DebugLabeler) Debug added in v1.0.19

func (d DebugLabeler) Debug(ctx context.Context, msg string, args ...interface{})

func (DebugLabeler) Trace added in v1.0.19

func (d DebugLabeler) Trace(ctx context.Context, f func() error, msg string) func()

type ReorderUsernameSource added in v1.0.19

type ReorderUsernameSource interface {
	LookupUsername(ctx context.Context, uid keybase1.UID) (libkb.NormalizedUsername, error)
}

Jump to

Keyboard shortcuts

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