Documentation
¶
Index ¶
- Constants
- func ApproveChat(ctx context.Context, token, conversationID string) error
- func ChatRequiresApproval(ctx context.Context, token, conversationID string) (bool, error)
- func DownloadFile(groupID groupme.ID, fileID, token string) (data []byte, filename, mime string, err error)
- func DownloadImage(url string) (data *[]byte, mime string, err error)
- func DownloadVideo(videoURL, token string) (data []byte, mime string, err error)
- func UploadFile(ctx context.Context, groupID groupme.ID, token, filename string, data []byte, ...) (fileID string, err error)
- func UploadVideo(ctx context.Context, token, senderID, groupID, recipientID string, data []byte, ...) (renderURL, thumbnailURL string, err error)
- type Client
- func (c Client) IndexAllChats(ctx context.Context) ([]*groupme.Chat, error)
- func (c Client) IndexAllGroups(ctx context.Context) ([]*groupme.Group, error)
- func (c Client) IndexAllRelations() ([]*groupme.User, error)
- func (c Client) LoadMessagesAfter(groupID groupme.ID, lastMessageID string, lastMessageFromMe bool, private bool) ([]*groupme.Message, error)
- func (c Client) LoadMessagesBefore(groupID, lastMessageID string, private bool) ([]*groupme.Message, error)
- func (c *Client) RemoveFromGroup(uid, groupID groupme.ID) error
- type Message
- type WSFayeClient
Constants ¶
const ( OldUserSuffix = "@c.groupme.com" NewUserSuffix = "@groupme.com" )
Variables ¶
This section is empty.
Functions ¶
func ApproveChat ¶
ApproveChat accepts a pending DM message request.
func ChatRequiresApproval ¶
ChatRequiresApproval reports whether the DM chat is a pending message request the logged-in user hasn't accepted yet.
func DownloadFile ¶
func DownloadFile(groupID groupme.ID, fileID, token string) (data []byte, filename, mime string, err error)
DownloadFile downloads a "file" attachment (GroupMe's group file-sharing feature, distinct from image/video message attachments) via file.groupme.com. This is a two-step API, both authenticated via X-Access-Token: one call resolves the file's name/mime type, a second fetches its bytes. groupID is the containing group's ID -- GroupMe's file-sharing feature is group-only, so this isn't expected to be called for a DM attachment.
Ported from the pre-2023 bridge's equivalent, which used to panic() on any request error here -- a network hiccup on a single file attachment would have taken down the entire bridge process. Rewritten to return an error instead, same as every other attachment download path.
func DownloadImage ¶
DownloadImage downloads an image attachment from GroupMe's image CDN (i.groupme.com), a plain unauthenticated GET.
func DownloadVideo ¶
DownloadVideo downloads a video attachment. Unlike images (a plain public GET) and files (a signed X-Access-Token API call, see DownloadFile), GroupMe's video CDN authenticates via a "token" cookie carrying the account's access token -- ported as-is from the pre-2023 bridge (the only place this was ever verified to work against the real API); not separately re-verified live in this revival, see NOTES.md.
func UploadFile ¶
func UploadFile(ctx context.Context, groupID groupme.ID, token, filename string, data []byte, mimeType string) (fileID string, err error)
UploadFile uploads an outgoing file (GroupMe's group file-sharing feature -- see DownloadFile's doc comment) and returns its file_id, for use as a "file" attachment's file_id. Reverse-engineered live the same way as UploadVideo; see NOTES.md "Outgoing video/file attachments".
Unlike video, this doesn't need a separate SAS-signed upload step -- file.groupme.com is GroupMe's own file-service (confirmed via its response headers, e.g. "x-gm-service: file-service"), not a direct Azure Blob Storage passthrough, so a plain X-Access-Token-authenticated POST of the raw bytes is enough on its own.
filename is passed as a "name" query parameter -- confirmed live to be the *only* thing that makes DownloadFile's metadata lookup come back populated afterward: neither a multipart form body (with a proper Content-Disposition filename -- the content didn't even transfer that way, this endpoint appears to not parse multipart at all), nor the Content-Type header, nor several other header/query-param names tried, had any effect. mime_type is then derived by GroupMe itself from filename's extension (confirmed live: a ".pdf" name produced "application/pdf" with no mime type passed anywhere else) -- so the mimeType parameter here is honored only as this function's own Content-Type request header (harmless either way, but not what actually determines the stored mime_type); pass a real filename with its real extension to get useful metadata out the other end.
func UploadVideo ¶
func UploadVideo(ctx context.Context, token, senderID, groupID, recipientID string, data []byte, extension, mimeType string) (renderURL, thumbnailURL string, err error)
UploadVideo uploads an outgoing video to GroupMe, returning the URLs to use as a "video" attachment's url/preview_url (see convertGroupMeMessage in pkg/connector for the incoming equivalent, and NOTES.md "Outgoing video/file attachments" for how this was reverse-engineered).
Two real HTTP calls, not one: first m.groupme.com/uploads is asked to create an upload session for a video of this size/extension belonging to this group or DM conversation, which hands back a one-time SAS URL scoped to Azure Blob Storage (cdn2.groupme.com) -- GroupMe's own X-Access-Token auth doesn't apply to that second request at all, unlike every other call in this file; the SAS signature in the URL itself is the only auth Azure wants, and a real attempt to PUT directly to cdn2.groupme.com with just X-Access-Token (no SAS) was confirmed live to fail with Azure's own "PublicAccessNotPermitted" error.
groupID and recipientID are mutually exclusive -- exactly one should be non-empty, matching whether this is a group or DM send (see the "You must provide either recipientId or groupId" validation error mentioned on createUploadRequest).
Types ¶
type Client ¶
func (Client) IndexAllChats ¶
func (Client) IndexAllGroups ¶
func (Client) LoadMessagesAfter ¶
func (Client) LoadMessagesBefore ¶
type WSFayeClient ¶
type WSFayeClient struct {
// contains filtered or unexported fields
}
WSFayeClient is a Bayeux client for GroupMe's push service (push.groupme.com/faye) that speaks the protocol over a WebSocket instead of the HTTP long-polling transport implemented by github.com/karmanyaahm/wray (vendored at thirdparty/wray/). GroupMe's current docs recommend websocket over long-polling, and the community-documented handshake declares `"supportedConnectionTypes":["websocket"]` -- see NOTES.md for the full investigation that motivated this.
It implements groupme.FayeClient (Listen/WaitSubscribe), so it's a drop-in replacement for the wray-backed FayeClient in this package: both satisfy the same interface consumed by groupme.PushSubscription.
func NewWSFayeClient ¶
func NewWSFayeClient(logger zerolog.Logger) *WSFayeClient
NewWSFayeClient creates a websocket-based Faye/Bayeux client for GroupMe's push service. Call Listen (typically via groupme.PushSubscription.StartListening) to begin connecting.
func (*WSFayeClient) Listen ¶
func (c *WSFayeClient) Listen(ctx context.Context)
func (*WSFayeClient) WaitSubscribe ¶
func (c *WSFayeClient) WaitSubscribe(ctx context.Context, channel, token string, msgChannel chan groupme.PushMessage) error