mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 12:52:24 +03:00
Linting
This commit is contained in:
parent
dcb9b9e179
commit
af5678a73e
4 changed files with 17 additions and 13 deletions
|
@ -72,7 +72,7 @@ func BuildEvent(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
proto.Version = verImpl
|
proto.Version = verImpl
|
||||||
if err := addPrevEventsToEvent(proto, eventsNeeded, queryRes); err != nil {
|
if err = addPrevEventsToEvent(proto, eventsNeeded, queryRes); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,9 +246,7 @@ func GenerateCreateContent(ctx context.Context, roomVer gomatrixserverlib.RoomVe
|
||||||
var finalAdditionalCreators []string
|
var finalAdditionalCreators []string
|
||||||
creatorsSet := make(map[string]struct{})
|
creatorsSet := make(map[string]struct{})
|
||||||
var unverifiedCreators []string
|
var unverifiedCreators []string
|
||||||
for _, add := range additionalCreators {
|
unverifiedCreators = append(unverifiedCreators, additionalCreators...)
|
||||||
unverifiedCreators = append(unverifiedCreators, add)
|
|
||||||
}
|
|
||||||
// they get added to any additional creators specified already
|
// they get added to any additional creators specified already
|
||||||
existingAdditionalCreators, ok := createContent["additional_creators"].([]any)
|
existingAdditionalCreators, ok := createContent["additional_creators"].([]any)
|
||||||
if ok {
|
if ok {
|
||||||
|
|
|
@ -90,7 +90,7 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
createEvent gomatrixserverlib.PDU
|
createEvent gomatrixserverlib.PDU
|
||||||
jsonErr *util.JSONResponse
|
jsonErr *util.JSONResponse
|
||||||
)
|
)
|
||||||
authEvents, err := gomatrixserverlib.NewAuthEvents(nil)
|
authEvents, _ := gomatrixserverlib.NewAuthEvents(nil)
|
||||||
if createRequest.CreateEvent != nil {
|
if createRequest.CreateEvent != nil {
|
||||||
createEvent, err = verImpl.NewEventFromTrustedJSON(createRequest.CreateEvent, false)
|
createEvent, err = verImpl.NewEventFromTrustedJSON(createRequest.CreateEvent, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -100,15 +100,21 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
JSON: spec.InternalServerError{},
|
JSON: spec.InternalServerError{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authEvents.AddEvent(createEvent)
|
if err = authEvents.AddEvent(createEvent); err != nil {
|
||||||
|
util.GetLogger(ctx).WithError(err).Error("gomatrixserverlib.AuthEvents.AddEvent failed")
|
||||||
|
return "", &util.JSONResponse{
|
||||||
|
Code: http.StatusInternalServerError,
|
||||||
|
JSON: spec.InternalServerError{},
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var additionalCreators []string
|
var additionalCreators []string
|
||||||
if createRequest.StatePreset == spec.PresetTrustedPrivateChat {
|
if createRequest.StatePreset == spec.PresetTrustedPrivateChat {
|
||||||
additionalCreators = createRequest.InvitedUsers
|
additionalCreators = createRequest.InvitedUsers
|
||||||
}
|
}
|
||||||
createContent, err := api.GenerateCreateContent(ctx, createRequest.RoomVersion, string(senderID), createRequest.CreationContent, additionalCreators)
|
createContent, contentErr := api.GenerateCreateContent(ctx, createRequest.RoomVersion, string(senderID), createRequest.CreationContent, additionalCreators)
|
||||||
if err != nil {
|
if contentErr != nil {
|
||||||
util.GetLogger(ctx).WithError(err).Error("GenerateCreateContent failed")
|
util.GetLogger(ctx).WithError(contentErr).Error("GenerateCreateContent failed")
|
||||||
return "", &util.JSONResponse{
|
return "", &util.JSONResponse{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
JSON: spec.BadJSON("invalid create content"),
|
JSON: spec.BadJSON("invalid create content"),
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (r *Upgrader) performRoomUpgrade(
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
}
|
}
|
||||||
oldRoomRes := &api.QueryLatestEventsAndStateResponse{}
|
oldRoomRes := &api.QueryLatestEventsAndStateResponse{}
|
||||||
if err := r.URSAPI.QueryLatestEventsAndState(ctx, oldRoomReq, oldRoomRes); err != nil {
|
if err = r.URSAPI.QueryLatestEventsAndState(ctx, oldRoomReq, oldRoomRes); err != nil {
|
||||||
return "", fmt.Errorf("Failed to get latest state: %s", err)
|
return "", fmt.Errorf("Failed to get latest state: %s", err)
|
||||||
}
|
}
|
||||||
var oldCreateEvent *types.HeaderedEvent
|
var oldCreateEvent *types.HeaderedEvent
|
||||||
|
@ -98,7 +98,7 @@ func (r *Upgrader) performRoomUpgrade(
|
||||||
} `json:"predecessor"`
|
} `json:"predecessor"`
|
||||||
}{}
|
}{}
|
||||||
// keep existing values in old room e.g type/m.federate
|
// keep existing values in old room e.g type/m.federate
|
||||||
if err := json.Unmarshal(oldCreateEvent.Content(), &content); err != nil {
|
if err = json.Unmarshal(oldCreateEvent.Content(), &content); err != nil {
|
||||||
return "", fmt.Errorf("failed to copy old create event content to new create event: %s", err)
|
return "", fmt.Errorf("failed to copy old create event content to new create event: %s", err)
|
||||||
}
|
}
|
||||||
content.Predecessor.RoomID = roomID
|
content.Predecessor.RoomID = roomID
|
||||||
|
@ -373,8 +373,8 @@ func (r *Upgrader) userIsAuthorized(ctx context.Context, senderID spec.SenderID,
|
||||||
// Return the events to create AFTER the new create event
|
// Return the events to create AFTER the new create event
|
||||||
// nolint:gocyclo
|
// nolint:gocyclo
|
||||||
func (r *Upgrader) generateInitialEvents(
|
func (r *Upgrader) generateInitialEvents(
|
||||||
ctx context.Context, oldRoom *api.QueryLatestEventsAndStateResponse, senderID spec.SenderID, roomID string, newVersion gomatrixserverlib.RoomVersion,
|
ctx context.Context, oldRoom *api.QueryLatestEventsAndStateResponse, senderID spec.SenderID, _ string, newVersion gomatrixserverlib.RoomVersion,
|
||||||
tombstoneEvent *types.HeaderedEvent, creators []string) ([]gomatrixserverlib.FledglingEvent, error) {
|
_ *types.HeaderedEvent, creators []string) ([]gomatrixserverlib.FledglingEvent, error) {
|
||||||
|
|
||||||
state := make(map[gomatrixserverlib.StateKeyTuple]*types.HeaderedEvent, len(oldRoom.StateEvents))
|
state := make(map[gomatrixserverlib.StateKeyTuple]*types.HeaderedEvent, len(oldRoom.StateEvents))
|
||||||
for _, event := range oldRoom.StateEvents {
|
for _, event := range oldRoom.StateEvents {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue