forked from
tangled.org/core
fork
Configure Feed
Select the types of activity you want to include in your feed.
this repo has no description
fork
Configure Feed
Select the types of activity you want to include in your feed.
1package eventconsumer
2
3import (
4 "fmt"
5 "net/url"
6)
7
8type SpindleSource struct {
9 Spindle string
10}
11
12func (s SpindleSource) Key() string {
13 return s.Spindle
14}
15
16func (s SpindleSource) Url(cursor int64, dev bool) (*url.URL, error) {
17 scheme := "wss"
18 if dev {
19 scheme = "ws"
20 }
21
22 u, err := url.Parse(scheme + "://" + s.Spindle + "/events")
23 if err != nil {
24 return nil, err
25 }
26
27 if cursor != 0 {
28 query := url.Values{}
29 query.Add("cursor", fmt.Sprintf("%d", cursor))
30 u.RawQuery = query.Encode()
31 }
32 return u, nil
33}
34
35func NewSpindleSource(spindle string) SpindleSource {
36 return SpindleSource{
37 Spindle: spindle,
38 }
39}