@@ 85,12 85,6 @@ func main() {
errorf("panic: %s\n%s", r, debug.Stack())
}
}()
- res, err := client.CreateFilter(electionFilter)
- if err != nil {
- errorf("couldn't create filter: %s", err)
- return
- }
- client.Store.SaveFilterID(client.UserID, res.FilterID)
err = client.Sync()
if err != nil {
errorf("error during sync: %s", err)
@@ 192,43 186,6 @@ func main() {
}
}
-var electionFilter = &mautrix.Filter{
- AccountData: mautrix.FilterPart{
- NotTypes: []event.Type{event.NewEventType("*")},
- },
- Presence: mautrix.FilterPart{
- NotTypes: []event.Type{event.NewEventType("*")},
- },
- Room: mautrix.RoomFilter{
- AccountData: mautrix.FilterPart{
- NotTypes: []event.Type{event.NewEventType("*")},
- },
- Ephemeral: mautrix.FilterPart{
- NotTypes: []event.Type{event.NewEventType("*")},
- },
- State: mautrix.FilterPart{
- Types: []event.Type{
- event.StateCreate,
- event.StateEncryption,
- event.StateMember,
- event.StateRoomName,
- },
- },
- Timeline: mautrix.FilterPart{
- // TODO figure out how to have no limit; -1 is giving me 500s
- Limit: 500,
- Types: []event.Type{
- election.CreateElectionMessage,
- election.JoinElectionMessage,
- election.StartElectionMessage,
- election.KeysMessage,
- election.EvalsMessage,
- election.SumMessage,
- },
- },
- },
-}
-
func debugEventHook(_ mautrix.EventSource, evt *event.Event) {
log.Debugf("<%[1]s> %[4]s (%[2]s/%[3]s)\n",
evt.Sender, evt.Type.String(), evt.ID,
@@ 6,6 6,8 @@ import (
log "github.com/sirupsen/logrus"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/event"
+ "maunium.net/go/mautrix/id"
+ "tallyard.xyz/election"
)
type TallyardSyncer struct {
@@ 32,3 34,42 @@ func NewTallyardSyncer() *TallyardSyncer {
}
return t
}
+
+func (s *TallyardSyncer) GetFilterJSON(userID id.UserID) *mautrix.Filter {
+ return &mautrix.Filter{
+ AccountData: mautrix.FilterPart{
+ NotTypes: []event.Type{event.NewEventType("*")},
+ },
+ Presence: mautrix.FilterPart{
+ NotTypes: []event.Type{event.NewEventType("*")},
+ },
+ Room: mautrix.RoomFilter{
+ AccountData: mautrix.FilterPart{
+ NotTypes: []event.Type{event.NewEventType("*")},
+ },
+ Ephemeral: mautrix.FilterPart{
+ NotTypes: []event.Type{event.NewEventType("*")},
+ },
+ State: mautrix.FilterPart{
+ Types: []event.Type{
+ event.StateCreate,
+ event.StateEncryption,
+ event.StateMember,
+ event.StateRoomName,
+ },
+ },
+ Timeline: mautrix.FilterPart{
+ // TODO figure out how to have no limit; -1 is giving me 500s
+ Limit: 500,
+ Types: []event.Type{
+ election.CreateElectionMessage,
+ election.JoinElectionMessage,
+ election.StartElectionMessage,
+ election.KeysMessage,
+ election.EvalsMessage,
+ election.SumMessage,
+ },
+ },
+ },
+ }
+}