Run gofmt

This commit is contained in:
Tulir Asokan 2021-09-22 10:52:01 -04:00
commit 00ca2be6a5
19 changed files with 27 additions and 18 deletions

View file

@ -21,7 +21,7 @@ type Registration struct {
AppToken string `yaml:"as_token"`
ServerToken string `yaml:"hs_token"`
SenderLocalpart string `yaml:"sender_localpart"`
RateLimited *bool `yaml:"rate_limited,omitempty"`
RateLimited *bool `yaml:"rate_limited,omitempty"`
Namespaces Namespaces `yaml:"namespaces"`
EphemeralEvents bool `yaml:"de.sorunome.msc2409.push_ephemeral,omitempty"`
Protocols []string `yaml:"protocols,omitempty"`

View file

@ -40,4 +40,4 @@ func (txnIDC *TransactionIDCache) MarkProcessed(txnID string) {
}
txnIDC.array[txnIDC.arrayPtr] = txnID
txnIDC.lock.Unlock()
}
}

View file

@ -25,6 +25,7 @@ const helloWorldRawFile = `{
}
}`
const random16Bytes = "\x85\xb4\x16/\xcaO\x1d\xe6\x7f\x95\xeb\xdb+g\x11\xb1"
var random16BytesBase64 = base64.StdEncoding.EncodeToString([]byte(random16Bytes))
func parseHelloWorld() *EncryptedFile {

View file

@ -45,12 +45,16 @@ const defaultPassphraseRounds = 100000
const exportPrefix = "-----BEGIN MEGOLM SESSION DATA-----\n"
const exportSuffix = "-----END MEGOLM SESSION DATA-----\n"
// Only version 0x01 is currently specified in the spec
const exportVersion1 = 0x01
// The standard for wrapping base64 is 76 bytes
const exportLineLengthLimit = 76
// Byte count for version + salt + iv + number of rounds
const exportHeaderLength = 1 + 16 + 16 + 4
// SHA-256 hash length
const exportHashLength = 32

View file

@ -4,6 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//go:build !nosas
// +build !nosas
package crypto

View file

@ -164,7 +164,7 @@ func (s *InboundGroupSession) GobDecode(rawPickled []byte) error {
func (s *InboundGroupSession) MarshalJSON() ([]byte, error) {
pickled := s.Pickle(pickleKey)
quotes := make([]byte, len(pickled) + 2)
quotes := make([]byte, len(pickled)+2)
quotes[0] = '"'
quotes[len(quotes)-1] = '"'
copy(quotes[1:len(quotes)-1], pickled)

View file

@ -164,7 +164,7 @@ func (s *Session) GobDecode(rawPickled []byte) error {
func (s *Session) MarshalJSON() ([]byte, error) {
pickled := s.Pickle(pickleKey)
quotes := make([]byte, len(pickled) + 2)
quotes := make([]byte, len(pickled)+2)
quotes[0] = '"'
quotes[len(quotes)-1] = '"'
copy(quotes[1:len(quotes)-1], pickled)

View file

@ -1,3 +1,4 @@
//go:build !nosas
// +build !nosas
package olm

View file

@ -32,7 +32,7 @@ type SQLCryptoStore struct {
PickleKey []byte
Account *OlmAccount
olmSessionCache map[id.SenderKey]map[id.SessionID]*OlmSession
olmSessionCache map[id.SenderKey]map[id.SessionID]*OlmSession
olmSessionCacheLock sync.Mutex
}

View file

@ -86,4 +86,4 @@ func TestKey_Encrypt(t *testing.T) {
decrypted, err := key1.Decrypt(evtType, encrypted)
assert.NoError(t, err)
assert.Equal(t, data, decrypted)
}
}

View file

@ -18,4 +18,4 @@ func (mach *OlmMachine) markDeviceForUnwedging(sender id.UserID, senderKey id.Se
func (mach *OlmMachine) checkIfWedged(evt *event.Event) {
//content := evt.Content.AsEncrypted()
// TODO implement
}
}

View file

@ -4,6 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//go:build !nosas
// +build !nosas
package crypto

View file

@ -20,7 +20,7 @@ import (
var (
ErrNoVerificationFromDevice = errors.New("from_device field is empty")
ErrNoVerificationMethods = errors.New("verification method list is empty")
ErrNoRelatesTo = errors.New("missing m.relates_to info")
ErrNoRelatesTo = errors.New("missing m.relates_to info")
)
// ProcessInRoomVerification is a callback that is to be called when a client receives a message

View file

@ -4,6 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//go:build !nosas
// +build !nosas
package crypto

View file

@ -42,4 +42,4 @@ type IgnoredUserListEventContent struct {
type IgnoredUser struct {
// This is an empty object
}
}

View file

@ -86,7 +86,7 @@ func (uri *ContentURI) UnmarshalJSON(raw []byte) (err error) {
} else if len(raw) < 2 || raw[0] != '"' || raw[len(raw)-1] != '"' {
return InputNotJSONString
}
parsed, err := ParseContentURIBytes(raw[1:len(raw)-1])
parsed, err := ParseContentURIBytes(raw[1 : len(raw)-1])
if err != nil {
return err
}

View file

@ -16,12 +16,12 @@ import (
)
var (
roomIDLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org"}
roomIDViaLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Via: []string{"maunium.net", "matrix.org"}}
roomAliasLink = id.MatrixURI{Sigil1: '#', MXID1: "someroom:example.org"}
roomIDEventLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Sigil2: '$', MXID2: "uOH4C9cK4HhMeFWkUXMbdF_dtndJ0j9je-kIK3XpV1s"}
roomIDLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org"}
roomIDViaLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Via: []string{"maunium.net", "matrix.org"}}
roomAliasLink = id.MatrixURI{Sigil1: '#', MXID1: "someroom:example.org"}
roomIDEventLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Sigil2: '$', MXID2: "uOH4C9cK4HhMeFWkUXMbdF_dtndJ0j9je-kIK3XpV1s"}
roomAliasEventLink = id.MatrixURI{Sigil1: '#', MXID1: "someroom:example.org", Sigil2: '$', MXID2: "uOH4C9cK4HhMeFWkUXMbdF_dtndJ0j9je-kIK3XpV1s"}
userLink = id.MatrixURI{Sigil1: '@', MXID1: "user:example.org"}
userLink = id.MatrixURI{Sigil1: '@', MXID1: "user:example.org"}
)
func TestMatrixURI_MatrixToURL(t *testing.T) {

View file

@ -18,7 +18,7 @@ func TestPushCondition_Match_KindEvent_MsgType(t *testing.T) {
condition := newMatchPushCondition("content.msgtype", "m.emote")
evt := newFakeEvent(event.EventMessage, &event.MessageEventContent{
MsgType: event.MsgEmote,
Body: "tests gomuks pushconditions",
Body: "tests gomuks pushconditions",
})
assert.True(t, condition.Match(blankTestRoom, evt))
}
@ -28,7 +28,7 @@ func TestPushCondition_Match_KindEvent_MsgType_Fail(t *testing.T) {
evt := newFakeEvent(event.EventMessage, &event.MessageEventContent{
MsgType: event.MsgText,
Body: "I'm testing gomuks pushconditions",
Body: "I'm testing gomuks pushconditions",
})
assert.False(t, condition.Match(blankTestRoom, evt))
}

View file

@ -20,7 +20,7 @@ func TestEventToPushRules(t *testing.T) {
evt := &event.Event{
Type: event.AccountDataPushRules,
Timestamp: 1523380910,
Content: event.Content{
Content: event.Content{
VeryRaw: json.RawMessage(JSONExamplePushRules),
},
}