diff --git a/src/github.com/matrix-org/dendrite/clientapi/consumers/roomserver.go b/src/github.com/matrix-org/dendrite/clientapi/consumers/roomserver.go index e915ddd25..0ee7c6bf0 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/consumers/roomserver.go +++ b/src/github.com/matrix-org/dendrite/clientapi/consumers/roomserver.go @@ -96,11 +96,7 @@ func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error { return err } - if err := s.db.UpdateMemberships(context.TODO(), events, output.NewRoomEvent.RemovesStateEventIDs); err != nil { - return err - } - - return nil + return s.db.UpdateMemberships(context.TODO(), events, output.NewRoomEvent.RemovesStateEventIDs) } // lookupStateEvents looks up the state events that are added by a new event. diff --git a/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go b/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go index 836591829..ea998e34a 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go +++ b/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go @@ -355,9 +355,5 @@ func emit3PIDInviteEvent( return err } - if err := producer.SendEvents(ctx, []gomatrixserverlib.Event{*event}, cfg.Matrix.ServerName); err != nil { - return err - } - - return nil + return producer.SendEvents(ctx, []gomatrixserverlib.Event{*event}, cfg.Matrix.ServerName) } diff --git a/src/github.com/matrix-org/dendrite/common/test/config.go b/src/github.com/matrix-org/dendrite/common/test/config.go index ad878c5b8..b9aec5d74 100644 --- a/src/github.com/matrix-org/dendrite/common/test/config.go +++ b/src/github.com/matrix-org/dendrite/common/test/config.go @@ -113,10 +113,7 @@ func WriteConfig(cfg *config.Dendrite, configDir string) error { if err != nil { return err } - if err = ioutil.WriteFile(filepath.Join(configDir, ConfigFile), data, 0666); err != nil { - return err - } - return nil + return ioutil.WriteFile(filepath.Join(configDir, ConfigFile), data, 0666) } // NewMatrixKey generates a new ed25519 matrix server key and writes it to a file. diff --git a/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go b/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go index 48f473669..715ec4d48 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go +++ b/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go @@ -63,11 +63,11 @@ func GetProfile( switch field { case "displayname": res = common.DisplayName{ - profile.DisplayName, + DisplayName: profile.DisplayName, } case "avatar_url": res = common.AvatarURL{ - profile.AvatarURL, + AvatarURL: profile.AvatarURL, } default: code = 400 @@ -75,8 +75,8 @@ func GetProfile( } } else { res = common.ProfileResponse{ - profile.AvatarURL, - profile.DisplayName, + AvatarURL: profile.AvatarURL, + DisplayName: profile.DisplayName, } } diff --git a/src/github.com/matrix-org/dendrite/federationapi/routing/send.go b/src/github.com/matrix-org/dendrite/federationapi/routing/send.go index 47c5efd0f..2103c2b8f 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/routing/send.go +++ b/src/github.com/matrix-org/dendrite/federationapi/routing/send.go @@ -170,11 +170,7 @@ func (t *txnReq) processEvent(e gomatrixserverlib.Event) error { // TODO: Check that the event is allowed by its auth_events. // pass the event to the roomserver - if err := t.producer.SendEvents(t.context, []gomatrixserverlib.Event{e}, api.DoNotSendToOtherServers); err != nil { - return err - } - - return nil + return t.producer.SendEvents(t.context, []gomatrixserverlib.Event{e}, api.DoNotSendToOtherServers) } func checkAllowedByState(e gomatrixserverlib.Event, stateEvents []gomatrixserverlib.Event) error { @@ -218,8 +214,5 @@ func (t *txnReq) processEventWithMissingState(e gomatrixserverlib.Event) error { return err } // pass the event along with the state to the roomserver - if err := t.producer.SendEventWithState(t.context, state, e); err != nil { - return err - } - return nil + return t.producer.SendEventWithState(t.context, state, e) } diff --git a/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go b/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go index ab97dc449..e84d639d0 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go +++ b/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go @@ -54,11 +54,7 @@ func (d *Database) prepare() error { return err } - if err = d.PartitionOffsetStatements.Prepare(d.db, "federationsender"); err != nil { - return err - } - - return nil + return d.PartitionOffsetStatements.Prepare(d.db, "federationsender") } // UpdateRoom updates the joined hosts for a room and returns what the joined diff --git a/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go b/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go index 64def9eb3..aafc0230a 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go @@ -22,7 +22,6 @@ import ( "net/url" "path" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/mediaapi/fileutils" @@ -31,6 +30,7 @@ import ( "github.com/matrix-org/dendrite/mediaapi/types" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" + log "github.com/sirupsen/logrus" ) // uploadRequest metadata included in or derivable from an upload request @@ -161,14 +161,10 @@ func (r *uploadRequest) doUpload( } } - if resErr := r.storeFileAndMetadata( + return r.storeFileAndMetadata( ctx, tmpDir, cfg.Media.AbsBasePath, db, cfg.Media.ThumbnailSizes, activeThumbnailGeneration, cfg.Media.MaxThumbnailGenerators, - ); resErr != nil { - return resErr - } - - return nil + ) } // Validate validates the uploadRequest fields diff --git a/src/github.com/matrix-org/dendrite/mediaapi/storage/sql.go b/src/github.com/matrix-org/dendrite/mediaapi/storage/sql.go index 024ab8bb8..1f8c7be30 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/storage/sql.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/storage/sql.go @@ -23,15 +23,13 @@ type statements struct { thumbnail thumbnailStatements } -func (s *statements) prepare(db *sql.DB) error { - var err error - +func (s *statements) prepare(db *sql.DB) (err error) { if err = s.media.prepare(db); err != nil { - return err + return } if err = s.thumbnail.prepare(db); err != nil { - return err + return } - return nil + return } diff --git a/src/github.com/matrix-org/dendrite/roomserver/alias/alias.go b/src/github.com/matrix-org/dendrite/roomserver/alias/alias.go index 5f5436ebf..7f41b4629 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/alias/alias.go +++ b/src/github.com/matrix-org/dendrite/roomserver/alias/alias.go @@ -79,11 +79,7 @@ func (r *RoomserverAliasAPI) SetRoomAlias( // At this point we've already committed the alias to the database so we // shouldn't cancel this request. // TODO: Ensure that we send unsent events when if server restarts. - if err := r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, request.RoomID); err != nil { - return err - } - - return nil + return r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, request.RoomID) } // GetAliasRoomID implements api.RoomserverAliasAPI @@ -123,11 +119,7 @@ func (r *RoomserverAliasAPI) RemoveRoomAlias( // At this point we've already committed the alias to the database so we // shouldn't cancel this request. // TODO: Ensure that we send unsent events when if server restarts. - if err := r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, roomID); err != nil { - return err - } - - return nil + return r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, roomID) } type roomAliasesContent struct { diff --git a/src/github.com/matrix-org/dendrite/roomserver/input/events.go b/src/github.com/matrix-org/dendrite/roomserver/input/events.go index 57b20961d..9032219ee 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/input/events.go +++ b/src/github.com/matrix-org/dendrite/roomserver/input/events.go @@ -129,11 +129,7 @@ func processRoomEvent( } // Update the extremities of the event graph for the room - if err := updateLatestEvents(ctx, db, ow, roomNID, stateAtEvent, event, input.SendAsServer); err != nil { - return err - } - - return nil + return updateLatestEvents(ctx, db, ow, roomNID, stateAtEvent, event, input.SendAsServer) } func processInviteEvent( diff --git a/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go b/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go index 30129a626..5767daab8 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go +++ b/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go @@ -162,11 +162,7 @@ func (u *latestEventsUpdater) doUpdateLatestEvents() error { return err } - if err = u.updater.MarkEventAsSent(u.stateAtEvent.EventNID); err != nil { - return err - } - - return nil + return u.updater.MarkEventAsSent(u.stateAtEvent.EventNID) } func (u *latestEventsUpdater) latestState() error {