mirror of https://github.com/matrix-org/go-neb.git
Browse Source
Add stub RSS Service. Add DefaultService. Add Poller interface.
Add stub RSS Service. Add DefaultService. Add Poller interface.
`DefaultService` serves as a useful no-op service to cut down on bloat when implementing new Services. This means we can add more methods more freely to the interface of `Service` without bogging down the Service implementation. `Poller` is an interface which contains a polling interval and a function to invoke. This will be used for RSS feeds. Implemented a stub `RSSService`.pull/76/head
Kegan Dougal
8 years ago
9 changed files with 119 additions and 28 deletions
-
13src/github.com/matrix-org/go-neb/database/db.go
-
27src/github.com/matrix-org/go-neb/database/schema.go
-
13src/github.com/matrix-org/go-neb/services/echo/echo.go
-
5src/github.com/matrix-org/go-neb/services/giphy/giphy.go
-
7src/github.com/matrix-org/go-neb/services/github/github.go
-
7src/github.com/matrix-org/go-neb/services/github/github_webhook.go
-
8src/github.com/matrix-org/go-neb/services/jira/jira.go
-
35src/github.com/matrix-org/go-neb/services/rss/rss.go
-
32src/github.com/matrix-org/go-neb/types/types.go
@ -0,0 +1,35 @@ |
|||
package services |
|||
|
|||
import ( |
|||
"github.com/matrix-org/go-neb/matrix" |
|||
"github.com/matrix-org/go-neb/types" |
|||
) |
|||
|
|||
type rssService struct { |
|||
types.DefaultService |
|||
id string |
|||
serviceUserID string |
|||
ClientUserID string `json:"client_user_id"` |
|||
Rooms map[string]struct { // room_id => {}
|
|||
Feeds map[string]struct { // URL => { }
|
|||
PollIntervalMs int `json:"poll_interval_ms"` |
|||
} `json:"feeds"` |
|||
} `json:"rooms"` |
|||
} |
|||
|
|||
func (s *rssService) ServiceUserID() string { return s.serviceUserID } |
|||
func (s *rssService) ServiceID() string { return s.id } |
|||
func (s *rssService) ServiceType() string { return "rss" } |
|||
|
|||
// Register will check the liveness of each RSS feed given. If all feeds check out okay, no error is returned.
|
|||
func (s *rssService) Register(oldService types.Service, client *matrix.Client) error { return nil } |
|||
|
|||
func init() { |
|||
types.RegisterService(func(serviceID, serviceUserID, webhookEndpointURL string) types.Service { |
|||
r := &rssService{ |
|||
id: serviceID, |
|||
serviceUserID: serviceUserID, |
|||
} |
|||
return r |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue