aboutsummaryrefslogtreecommitdiff
path: root/matrix
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-22 17:24:47 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-22 17:24:47 +0300
commitcc28c7b65f9aa53a6bb1f0162f6124e1ad5edac2 (patch)
treedda36235956309fc4fb514632a3ab7cdd18b4abd /matrix
parentcce79ab7d8481a06054166049876c8a2cbb3418f (diff)
Gofmt
Diffstat (limited to 'matrix')
-rw-r--r--matrix/matrix.go2
-rw-r--r--matrix/matrix_test.go14
-rw-r--r--matrix/pushrules/condition.go2
-rw-r--r--matrix/pushrules/rule.go4
-rw-r--r--matrix/pushrules/rule_array_test.go4
-rw-r--r--matrix/pushrules/rule_test.go43
-rw-r--r--matrix/rooms/room.go4
-rw-r--r--matrix/sync.go16
8 files changed, 44 insertions, 45 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go
index 264cff8..c79f8fd 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -337,7 +337,7 @@ func (c *Container) HandleReadReceipt(source EventSource, evt *gomatrix.Event) {
c.ui.Render()
}
-func (c *Container) parseDirectChatInfo(evt *gomatrix.Event) (map[*rooms.Room]bool){
+func (c *Container) parseDirectChatInfo(evt *gomatrix.Event) map[*rooms.Room]bool {
directChats := make(map[*rooms.Room]bool)
for _, rawRoomIDList := range evt.Content {
roomIDList, ok := rawRoomIDList.([]interface{})
diff --git a/matrix/matrix_test.go b/matrix/matrix_test.go
index 753fda0..b6511ec 100644
--- a/matrix/matrix_test.go
+++ b/matrix/matrix_test.go
@@ -17,16 +17,16 @@
package matrix
import (
- "testing"
- "maunium.net/go/gomuks/config"
- "github.com/stretchr/testify/assert"
- "net/http"
- "maunium.net/go/gomatrix"
- "strings"
+ "encoding/json"
"fmt"
+ "github.com/stretchr/testify/assert"
"io/ioutil"
- "encoding/json"
+ "maunium.net/go/gomatrix"
+ "maunium.net/go/gomuks/config"
+ "net/http"
"os"
+ "strings"
+ "testing"
)
func TestContainer_InitClient_Empty(t *testing.T) {
diff --git a/matrix/pushrules/condition.go b/matrix/pushrules/condition.go
index 6607323..08958a3 100644
--- a/matrix/pushrules/condition.go
+++ b/matrix/pushrules/condition.go
@@ -21,8 +21,8 @@ import (
"strconv"
"strings"
- "maunium.net/go/gomuks/lib/glob"
"maunium.net/go/gomatrix"
+ "maunium.net/go/gomuks/lib/glob"
"maunium.net/go/gomuks/matrix/rooms"
)
diff --git a/matrix/pushrules/rule.go b/matrix/pushrules/rule.go
index ddb264e..5ede895 100644
--- a/matrix/pushrules/rule.go
+++ b/matrix/pushrules/rule.go
@@ -17,9 +17,9 @@
package pushrules
import (
- "maunium.net/go/gomuks/lib/glob"
- "maunium.net/go/gomatrix"
"encoding/gob"
+ "maunium.net/go/gomatrix"
+ "maunium.net/go/gomuks/lib/glob"
)
func init() {
diff --git a/matrix/pushrules/rule_array_test.go b/matrix/pushrules/rule_array_test.go
index fdecd9c..9396411 100644
--- a/matrix/pushrules/rule_array_test.go
+++ b/matrix/pushrules/rule_array_test.go
@@ -17,9 +17,9 @@
package pushrules_test
import (
- "testing"
- "maunium.net/go/gomuks/matrix/pushrules"
"github.com/stretchr/testify/assert"
+ "maunium.net/go/gomuks/matrix/pushrules"
+ "testing"
)
func TestPushRuleArray_GetActions_FirstMatchReturns(t *testing.T) {
diff --git a/matrix/pushrules/rule_test.go b/matrix/pushrules/rule_test.go
index 3d3f03c..bedcfca 100644
--- a/matrix/pushrules/rule_test.go
+++ b/matrix/pushrules/rule_test.go
@@ -17,17 +17,17 @@
package pushrules_test
import (
- "testing"
"github.com/stretchr/testify/assert"
"maunium.net/go/gomuks/matrix/pushrules"
+ "testing"
)
func TestPushRule_Match_Conditions(t *testing.T) {
cond1 := newMatchPushCondition("content.msgtype", "m.emote")
cond2 := newMatchPushCondition("content.body", "*pushrules")
rule := &pushrules.PushRule{
- Type: pushrules.OverrideRule,
- Enabled: true,
+ Type: pushrules.OverrideRule,
+ Enabled: true,
Conditions: []*pushrules.PushCondition{cond1, cond2},
}
@@ -42,8 +42,8 @@ func TestPushRule_Match_Conditions_Disabled(t *testing.T) {
cond1 := newMatchPushCondition("content.msgtype", "m.emote")
cond2 := newMatchPushCondition("content.body", "*pushrules")
rule := &pushrules.PushRule{
- Type: pushrules.OverrideRule,
- Enabled: false,
+ Type: pushrules.OverrideRule,
+ Enabled: false,
Conditions: []*pushrules.PushCondition{cond1, cond2},
}
@@ -58,8 +58,8 @@ func TestPushRule_Match_Conditions_FailIfOneFails(t *testing.T) {
cond1 := newMatchPushCondition("content.msgtype", "m.emote")
cond2 := newMatchPushCondition("content.body", "*pushrules")
rule := &pushrules.PushRule{
- Type: pushrules.OverrideRule,
- Enabled: true,
+ Type: pushrules.OverrideRule,
+ Enabled: true,
Conditions: []*pushrules.PushCondition{cond1, cond2},
}
@@ -72,7 +72,7 @@ func TestPushRule_Match_Conditions_FailIfOneFails(t *testing.T) {
func TestPushRule_Match_Content(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.ContentRule,
+ Type: pushrules.ContentRule,
Enabled: true,
Pattern: "is testing*",
}
@@ -86,7 +86,7 @@ func TestPushRule_Match_Content(t *testing.T) {
func TestPushRule_Match_Content_Fail(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.ContentRule,
+ Type: pushrules.ContentRule,
Enabled: true,
Pattern: "is testing*",
}
@@ -100,7 +100,7 @@ func TestPushRule_Match_Content_Fail(t *testing.T) {
func TestPushRule_Match_Content_ImplicitGlob(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.ContentRule,
+ Type: pushrules.ContentRule,
Enabled: true,
Pattern: "testing",
}
@@ -114,7 +114,7 @@ func TestPushRule_Match_Content_ImplicitGlob(t *testing.T) {
func TestPushRule_Match_Content_IllegalGlob(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.ContentRule,
+ Type: pushrules.ContentRule,
Enabled: true,
Pattern: "this is not a valid glo[b",
}
@@ -128,9 +128,9 @@ func TestPushRule_Match_Content_IllegalGlob(t *testing.T) {
func TestPushRule_Match_Room(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.RoomRule,
+ Type: pushrules.RoomRule,
Enabled: true,
- RuleID: "!fakeroom:maunium.net",
+ RuleID: "!fakeroom:maunium.net",
}
event := newFakeEvent("m.room.message", map[string]interface{}{})
@@ -139,21 +139,20 @@ func TestPushRule_Match_Room(t *testing.T) {
func TestPushRule_Match_Room_Fail(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.RoomRule,
+ Type: pushrules.RoomRule,
Enabled: true,
- RuleID: "!otherroom:maunium.net",
+ RuleID: "!otherroom:maunium.net",
}
event := newFakeEvent("m.room.message", map[string]interface{}{})
assert.False(t, rule.Match(blankTestRoom, event))
}
-
func TestPushRule_Match_Sender(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.SenderRule,
+ Type: pushrules.SenderRule,
Enabled: true,
- RuleID: "@tulir:maunium.net",
+ RuleID: "@tulir:maunium.net",
}
event := newFakeEvent("m.room.message", map[string]interface{}{})
@@ -162,9 +161,9 @@ func TestPushRule_Match_Sender(t *testing.T) {
func TestPushRule_Match_Sender_Fail(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.RoomRule,
+ Type: pushrules.RoomRule,
Enabled: true,
- RuleID: "@someone:matrix.org",
+ RuleID: "@someone:matrix.org",
}
event := newFakeEvent("m.room.message", map[string]interface{}{})
@@ -173,9 +172,9 @@ func TestPushRule_Match_Sender_Fail(t *testing.T) {
func TestPushRule_Match_UnknownTypeAlwaysFail(t *testing.T) {
rule := &pushrules.PushRule{
- Type: pushrules.PushRuleType("foobar"),
+ Type: pushrules.PushRuleType("foobar"),
Enabled: true,
- RuleID: "@someone:matrix.org",
+ RuleID: "@someone:matrix.org",
}
event := newFakeEvent("m.room.message", map[string]interface{}{})
diff --git a/matrix/rooms/room.go b/matrix/rooms/room.go
index 8a543e8..598f0ea 100644
--- a/matrix/rooms/room.go
+++ b/matrix/rooms/room.go
@@ -22,10 +22,10 @@ import (
"sync"
"time"
+ "encoding/gob"
"maunium.net/go/gomatrix"
"maunium.net/go/gomuks/debug"
"os"
- "encoding/gob"
)
func init() {
@@ -36,7 +36,7 @@ func init() {
type RoomNameSource int
const (
- ExplicitRoomName RoomNameSource = iota
+ ExplicitRoomName RoomNameSource = iota
CanonicalAliasRoomName
AliasRoomName
MemberRoomName
diff --git a/matrix/sync.go b/matrix/sync.go
index 330a8c5..3f6860a 100644
--- a/matrix/sync.go
+++ b/matrix/sync.go
@@ -34,7 +34,7 @@ type SyncerSession interface {
type EventSource int
const (
- EventSourcePresence EventSource = 1 << iota
+ EventSourcePresence EventSource = 1 << iota
EventSourceJoin
EventSourceInvite
EventSourceLeave
@@ -72,10 +72,10 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er
for roomID, roomData := range res.Rooms.Join {
room := s.Session.GetRoom(roomID)
- s.processSyncEvents(room, roomData.State.Events, EventSourceJoin | EventSourceState, false)
- s.processSyncEvents(room, roomData.Timeline.Events, EventSourceJoin | EventSourceTimeline, false)
- s.processSyncEvents(room, roomData.Ephemeral.Events, EventSourceJoin | EventSourceEphemeral, false)
- s.processSyncEvents(room, roomData.AccountData.Events, EventSourceJoin | EventSourceAccountData, false)
+ s.processSyncEvents(room, roomData.State.Events, EventSourceJoin|EventSourceState, false)
+ s.processSyncEvents(room, roomData.Timeline.Events, EventSourceJoin|EventSourceTimeline, false)
+ s.processSyncEvents(room, roomData.Ephemeral.Events, EventSourceJoin|EventSourceEphemeral, false)
+ s.processSyncEvents(room, roomData.AccountData.Events, EventSourceJoin|EventSourceAccountData, false)
if len(room.PrevBatch) == 0 {
room.PrevBatch = roomData.Timeline.PrevBatch
@@ -84,14 +84,14 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er
for roomID, roomData := range res.Rooms.Invite {
room := s.Session.GetRoom(roomID)
- s.processSyncEvents(room, roomData.State.Events, EventSourceInvite | EventSourceState, false)
+ s.processSyncEvents(room, roomData.State.Events, EventSourceInvite|EventSourceState, false)
}
for roomID, roomData := range res.Rooms.Leave {
room := s.Session.GetRoom(roomID)
room.HasLeft = true
- s.processSyncEvents(room, roomData.State.Events, EventSourceLeave | EventSourceState, true)
- s.processSyncEvents(room, roomData.Timeline.Events, EventSourceLeave | EventSourceTimeline, false)
+ s.processSyncEvents(room, roomData.State.Events, EventSourceLeave|EventSourceState, true)
+ s.processSyncEvents(room, roomData.Timeline.Events, EventSourceLeave|EventSourceTimeline, false)
if len(room.PrevBatch) == 0 {
room.PrevBatch = roomData.Timeline.PrevBatch