mirror of
https://github.com/matrix-org/dendrite
synced 2024-06-13 09:58:59 +02:00
Wire everything up
This commit is contained in:
parent
3bbe097162
commit
5567da100c
|
@ -2359,7 +2359,9 @@ func TestReportEvent(t *testing.T) {
|
|||
eventToReport := room.CreateAndInsert(t, alice, "m.room.message", map[string]interface{}{"body": "hello world"})
|
||||
|
||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
|
||||
if dbType == test.DBTypeSQLite {
|
||||
t.Skip()
|
||||
}
|
||||
cfg, processCtx, close := testrig.CreateConfig(t, dbType)
|
||||
routers := httputil.NewRouters()
|
||||
cm := sqlutil.NewConnectionManager(processCtx, cfg.Global.DatabaseOptions)
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
type reportEventRequest struct {
|
||||
Reason string `json:"reason"`
|
||||
Score int `json:"score"`
|
||||
Score int64 `json:"score"`
|
||||
}
|
||||
|
||||
func ReportEvent(
|
||||
|
@ -80,6 +80,14 @@ func ReportEvent(
|
|||
|
||||
// TODO: Store the event
|
||||
|
||||
_, err = rsAPI.InsertReportedEvent(req.Context(), roomID, eventID, device.UserID, report.Reason, report.Score)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: spec.InternalServerError{Err: err.Error()},
|
||||
}
|
||||
}
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct{}{},
|
||||
|
|
|
@ -223,6 +223,7 @@ type ClientRoomserverAPI interface {
|
|||
UserRoomPrivateKeyCreator
|
||||
QueryRoomHierarchyAPI
|
||||
DefaultRoomVersionAPI
|
||||
|
||||
QueryMembershipForUser(ctx context.Context, req *QueryMembershipForUserRequest, res *QueryMembershipForUserResponse) error
|
||||
QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
|
||||
QueryRoomsForUser(ctx context.Context, userID spec.UserID, desiredMembership string) ([]spec.RoomID, error)
|
||||
|
@ -264,6 +265,12 @@ type ClientRoomserverAPI interface {
|
|||
RemoveRoomAlias(ctx context.Context, senderID spec.SenderID, alias string) (aliasFound bool, aliasRemoved bool, err error)
|
||||
|
||||
SigningIdentityFor(ctx context.Context, roomID spec.RoomID, senderID spec.UserID) (fclient.SigningIdentity, error)
|
||||
|
||||
InsertReportedEvent(
|
||||
ctx context.Context,
|
||||
roomID, eventID, reportingUserID, reason string,
|
||||
score int64,
|
||||
) (int64, error)
|
||||
}
|
||||
|
||||
type UserRoomserverAPI interface {
|
||||
|
|
|
@ -340,3 +340,11 @@ func (r *RoomserverInternalAPI) SigningIdentityFor(ctx context.Context, roomID s
|
|||
func (r *RoomserverInternalAPI) AssignRoomNID(ctx context.Context, roomID spec.RoomID, roomVersion gomatrixserverlib.RoomVersion) (roomNID types.RoomNID, err error) {
|
||||
return r.DB.AssignRoomNID(ctx, roomID, roomVersion)
|
||||
}
|
||||
|
||||
func (r *RoomserverInternalAPI) InsertReportedEvent(
|
||||
ctx context.Context,
|
||||
roomID, eventID, reportingUserID, reason string,
|
||||
score int64,
|
||||
) (int64, error) {
|
||||
return r.DB.InsertReportedEvent(ctx, roomID, eventID, reportingUserID, reason, score)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue