edge

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package edge provides a limited implementation of undocumented Slack Edge API necessary to get the data from a slack workspace.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotOK = errors.New("server returned NOT OK")

Functions

This section is empty.

Types

type BaseRequest

type BaseRequest struct {
	Token string `json:"token"`
}

func (*BaseRequest) IsTokenSet

func (r *BaseRequest) IsTokenSet() bool

func (*BaseRequest) SetToken

func (r *BaseRequest) SetToken(token string)

type BaseResponse

type BaseResponse struct {
	Ok    bool   `json:"ok"`
	Error string `json:"error"`
}

type Client

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

func New

func New(teamID string, token string, cookies []*http.Cookie) (*Client, error)

func NewWithProvider

func NewWithProvider(teamID string, prov auth.Provider) (*Client, error)

func (*Client) ChannelMembership

func (cl *Client) ChannelMembership(ctx context.Context, req *UserMembershipRequest) (*UserMembershipResponse, error)

ChannelMembership calls channels.membership endpoint.

func (*Client) GetUsers

func (cl *Client) GetUsers(ctx context.Context, ids []string) ([]UserInfo, error)

GetUsers returns users from the slack edge api for the channel. User IDs should be provided by the caller. If ids is empty, does nothing.

This tries to replicate the logic of the Slack client, when it fetches the channel users while being logged in as a guest user.

func (*Client) ParseResponse

func (cl *Client) ParseResponse(req any, resp *http.Response) error

func (*Client) Post

func (cl *Client) Post(_ context.Context, path string, req PostRequest) (*http.Response, error)

func (*Client) Raw

func (cl *Client) Raw() *http.Client

func (*Client) UsersInfo

func (cl *Client) UsersInfo(ctx context.Context, req *UsersInfoRequest) (*UserInfoResponse, error)

UsersInfo calls a users.info endpoint. This endpoint does not return results straight away. It may return "pending ids", and when it does, it should be called again to get the actual user info (see Client.GetUsers).

type PostRequest

type PostRequest interface {
	SetToken(string)
	IsTokenSet() bool
}

type Profile

type Profile struct {
	Title                  string  `json:"title"`
	Phone                  string  `json:"phone"`
	Skype                  string  `json:"skype"`
	RealName               string  `json:"real_name"`
	RealNameNormalized     string  `json:"real_name_normalized"`
	DisplayName            string  `json:"display_name"`
	DisplayNameNormalized  string  `json:"display_name_normalized"`
	Fields                 any     `json:"fields"`
	StatusText             string  `json:"status_text"`
	StatusEmoji            string  `json:"status_emoji"`
	StatusEmojiDisplayInfo []any   `json:"status_emoji_display_info"`
	StatusExpiration       int64   `json:"status_expiration"`
	AvatarHash             string  `json:"avatar_hash"`
	GuestInvitedBy         string  `json:"guest_invited_by"`
	ImageOriginal          *string `json:"image_original,omitempty"`
	IsCustomImage          *bool   `json:"is_custom_image,omitempty"`
	Email                  string  `json:"email"`
	FirstName              *string `json:"first_name,omitempty"`
	LastName               *string `json:"last_name,omitempty"`
	StatusTextCanonical    string  `json:"status_text_canonical"`
	Team                   string  `json:"team"`
}

type User

type User struct {
	ID                     string  `json:"id"`
	TeamID                 string  `json:"team_id"`
	Name                   string  `json:"name"`
	Deleted                bool    `json:"deleted"`
	Color                  string  `json:"color"`
	RealName               string  `json:"real_name"`
	Tz                     string  `json:"tz"`
	TzLabel                string  `json:"tz_label"`
	TzOffset               int64   `json:"tz_offset"`
	Profile                Profile `json:"profile"`
	IsAdmin                bool    `json:"is_admin"`
	IsOwner                bool    `json:"is_owner"`
	IsPrimaryOwner         bool    `json:"is_primary_owner"`
	IsRestricted           bool    `json:"is_restricted"`
	IsUltraRestricted      bool    `json:"is_ultra_restricted"`
	IsBot                  bool    `json:"is_bot"`
	IsAppUser              bool    `json:"is_app_user"`
	Updated                int64   `json:"updated"`
	IsEmailConfirmed       bool    `json:"is_email_confirmed"`
	WhoCanShareContactCard string  `json:"who_can_share_contact_card"`
}

type UserInfo

type UserInfo struct {
	ID                     string  `json:"id"`
	TeamID                 string  `json:"team_id"`
	Name                   string  `json:"name"`
	Color                  string  `json:"color"`
	IsBot                  bool    `json:"is_bot"`
	IsAppUser              bool    `json:"is_app_user"`
	Deleted                bool    `json:"deleted"`
	Profile                Profile `json:"profile"`
	IsStranger             bool    `json:"is_stranger"`
	Updated                int64   `json:"updated"`
	WhoCanShareContactCard string  `json:"who_can_share_contact_card"`
}

type UserInfoResponse

type UserInfoResponse struct {
	Results     []UserInfo      `json:"results"`
	FailedIDS   []string        `json:"failed_ids"`
	PendingIDS  []string        `json:"pending_ids"`
	CanInteract map[string]bool `json:"can_interact"`
	BaseResponse
}

type UserMembershipRequest

type UserMembershipRequest struct {
	BaseRequest
	Channel string   `json:"channel"`
	Users   []string `json:"users"`
	AsAdmin bool     `json:"as_admin"`
}

type UserMembershipResponse

type UserMembershipResponse struct {
	Channel    string   `json:"channel"`
	NonMembers []string `json:"non_members"`
	BaseResponse
}

type UsersInfoRequest

type UsersInfoRequest struct {
	BaseRequest
	CheckInteraction        bool             `json:"check_interaction"`
	IncludeProfileOnlyUsers bool             `json:"include_profile_only_users"`
	UpdatedIDS              map[string]int64 `json:"updated_ids"`
}

type UsersListRequest

type UsersListRequest struct {
	BaseRequest
	Channels     []string `json:"channels"`
	PresentFirst bool     `json:"present_first"`
	Filter       string   `json:"filter"`
	Count        int64    `json:"count"`
}

type UsersListResponse

type UsersListResponse struct {
	Results []User `json:"results"`
	BaseResponse
}

Jump to

Keyboard shortcuts

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