Move BuildEvent to common package
This is in preperation for implementing various federation APIs that
need to build events.
MODIFY
src/github.com/matrix-org/dendrite/clientapi/routing/joinroom.go
src/github.com/matrix-org/dendrite/clientapi/routing/joinroom.go
@@ -22,10 +22,10 @@ import (
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
- "github.com/matrix-org/dendrite/clientapi/events"
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/producers"
+ "github.com/matrix-org/dendrite/common"
"github.com/matrix-org/dendrite/common/config"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrix"
@@ -215,7 +215,7 @@ func (r joinRoomReq) joinRoomUsingServers(
}
var queryRes api.QueryLatestEventsAndStateResponse
- event, err := events.BuildEvent(r.req.Context(), &eb, r.cfg, r.queryAPI, &queryRes)
+ event, err := common.BuildEvent(r.req.Context(), &eb, r.cfg, r.queryAPI, &queryRes)
if err == nil {
if err = r.producer.SendEvents(r.req.Context(), []gomatrixserverlib.Event{*event}, r.cfg.Matrix.ServerName); err != nil {
return httputil.LogThenError(r.req, err)
@@ -227,7 +227,7 @@ func (r joinRoomReq) joinRoomUsingServers(
}{roomID},
}
}
- if err != events.ErrRoomNoExists {
+ if err != common.ErrRoomNoExists {
return httputil.LogThenError(r.req, err)
}

MODIFY
src/github.com/matrix-org/dendrite/clientapi/routing/membership.go
src/github.com/matrix-org/dendrite/clientapi/routing/membership.go
@@ -21,7 +21,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
- "github.com/matrix-org/dendrite/clientapi/events"
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/producers"
@@ -62,7 +61,7 @@ func SendMembership(
Code: 400,
JSON: jsonerror.NotTrusted(body.IDServer),
}
- } else if err == events.ErrRoomNoExists {
+ } else if err == common.ErrRoomNoExists {
return util.JSONResponse{
Code: 404,
JSON: jsonerror.NotFound(err.Error()),
@@ -89,7 +88,7 @@ func SendMembership(
Code: 400,
JSON: jsonerror.BadJSON(err.Error()),
}
- } else if err == events.ErrRoomNoExists {
+ } else if err == common.ErrRoomNoExists {
return util.JSONResponse{
Code: 404,
JSON: jsonerror.NotFound(err.Error()),
@@ -149,7 +148,7 @@ func buildMembershipEvent(
return nil, err
}
- return events.BuildEvent(ctx, &builder, cfg, queryAPI, nil)
+ return common.BuildEvent(ctx, &builder, cfg, queryAPI, nil)
}
// loadProfile lookups the profile of a given user from the database and returns

MODIFY
src/github.com/matrix-org/dendrite/clientapi/routing/profile.go
src/github.com/matrix-org/dendrite/clientapi/routing/profile.go
@@ -20,7 +20,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
- "github.com/matrix-org/dendrite/clientapi/events"
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/producers"
@@ -285,7 +284,7 @@ func buildMembershipEvents(
return nil, err
}
- event, err := events.BuildEvent(ctx, &builder, *cfg, queryAPI, nil)
+ event, err := common.BuildEvent(ctx, &builder, *cfg, queryAPI, nil)
if err != nil {
return nil, err
}

MODIFY
src/github.com/matrix-org/dendrite/clientapi/routing/sendevent.go
src/github.com/matrix-org/dendrite/clientapi/routing/sendevent.go
@@ -18,10 +18,10 @@ import (
"net/http"
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
- "github.com/matrix-org/dendrite/clientapi/events"
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/producers"
+ "github.com/matrix-org/dendrite/common"
"github.com/matrix-org/dendrite/common/config"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
@@ -67,8 +67,8 @@ func SendEvent(
}
var queryRes api.QueryLatestEventsAndStateResponse
- e, err := events.BuildEvent(req.Context(), &builder, cfg, queryAPI, &queryRes)
- if err == events.ErrRoomNoExists {
+ e, err := common.BuildEvent(req.Context(), &builder, cfg, queryAPI, &queryRes)
+ if err == common.ErrRoomNoExists {
return util.JSONResponse{
Code: 404,
JSON: jsonerror.NotFound("Room does not exist"),

MODIFY
src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go
src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go
@@ -26,7 +26,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
- "github.com/matrix-org/dendrite/clientapi/events"
"github.com/matrix-org/dendrite/clientapi/producers"
"github.com/matrix-org/dendrite/common"
"github.com/matrix-org/dendrite/common/config"
@@ -351,7 +350,7 @@ func emit3PIDInviteEvent(
}
var queryRes *api.QueryLatestEventsAndStateResponse
- event, err := events.BuildEvent(ctx, builder, cfg, queryAPI, queryRes)
+ event, err := common.BuildEvent(ctx, builder, cfg, queryAPI, queryRes)
if err != nil {
return err
}

RENAME
src/github.com/matrix-org/dendrite/clientapi/events/events.go
src/github.com/matrix-org/dendrite/common/events.go
// See the License for the specific language governing permissions and
// limitations under the License.
-package events
+package common
import (
"context"

Move BuildEvent to common package (#315)

This is in preperation for implementing various federation APIs that
need to build events.