aboutsummaryrefslogtreecommitdiff
path: root/roomserver/api/api_trace.go
blob: a478eeb9a8fb86755c88bdd25fb0ba0782c89e06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package api

import (
	"context"
	"encoding/json"
	"fmt"

	fsAPI "github.com/matrix-org/dendrite/federationsender/api"
	"github.com/matrix-org/util"
)

// RoomserverInternalAPITrace wraps a RoomserverInternalAPI and logs the
// complete request/response/error
type RoomserverInternalAPITrace struct {
	Impl RoomserverInternalAPI
}

func (t *RoomserverInternalAPITrace) SetFederationSenderAPI(fsAPI fsAPI.FederationSenderInternalAPI) {
	t.Impl.SetFederationSenderAPI(fsAPI)
}

func (t *RoomserverInternalAPITrace) InputRoomEvents(
	ctx context.Context,
	req *InputRoomEventsRequest,
	res *InputRoomEventsResponse,
) error {
	err := t.Impl.InputRoomEvents(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("InputRoomEvents req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) PerformJoin(
	ctx context.Context,
	req *PerformJoinRequest,
	res *PerformJoinResponse,
) error {
	err := t.Impl.PerformJoin(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("PerformJoin req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) PerformLeave(
	ctx context.Context,
	req *PerformLeaveRequest,
	res *PerformLeaveResponse,
) error {
	err := t.Impl.PerformLeave(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("PerformLeave req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryLatestEventsAndState(
	ctx context.Context,
	req *QueryLatestEventsAndStateRequest,
	res *QueryLatestEventsAndStateResponse,
) error {
	err := t.Impl.QueryLatestEventsAndState(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryLatestEventsAndState req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryStateAfterEvents(
	ctx context.Context,
	req *QueryStateAfterEventsRequest,
	res *QueryStateAfterEventsResponse,
) error {
	err := t.Impl.QueryStateAfterEvents(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryStateAfterEvents req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryEventsByID(
	ctx context.Context,
	req *QueryEventsByIDRequest,
	res *QueryEventsByIDResponse,
) error {
	err := t.Impl.QueryEventsByID(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryEventsByID req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryMembershipForUser(
	ctx context.Context,
	req *QueryMembershipForUserRequest,
	res *QueryMembershipForUserResponse,
) error {
	err := t.Impl.QueryMembershipForUser(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryMembershipForUser req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryMembershipsForRoom(
	ctx context.Context,
	req *QueryMembershipsForRoomRequest,
	res *QueryMembershipsForRoomResponse,
) error {
	err := t.Impl.QueryMembershipsForRoom(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryMembershipsForRoom req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryServerAllowedToSeeEvent(
	ctx context.Context,
	req *QueryServerAllowedToSeeEventRequest,
	res *QueryServerAllowedToSeeEventResponse,
) error {
	err := t.Impl.QueryServerAllowedToSeeEvent(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryServerAllowedToSeeEvent req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryMissingEvents(
	ctx context.Context,
	req *QueryMissingEventsRequest,
	res *QueryMissingEventsResponse,
) error {
	err := t.Impl.QueryMissingEvents(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryMissingEvents req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryStateAndAuthChain(
	ctx context.Context,
	req *QueryStateAndAuthChainRequest,
	res *QueryStateAndAuthChainResponse,
) error {
	err := t.Impl.QueryStateAndAuthChain(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryStateAndAuthChain req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) PerformBackfill(
	ctx context.Context,
	req *PerformBackfillRequest,
	res *PerformBackfillResponse,
) error {
	err := t.Impl.PerformBackfill(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("PerformBackfill req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryRoomVersionCapabilities(
	ctx context.Context,
	req *QueryRoomVersionCapabilitiesRequest,
	res *QueryRoomVersionCapabilitiesResponse,
) error {
	err := t.Impl.QueryRoomVersionCapabilities(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryRoomVersionCapabilities req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) QueryRoomVersionForRoom(
	ctx context.Context,
	req *QueryRoomVersionForRoomRequest,
	res *QueryRoomVersionForRoomResponse,
) error {
	err := t.Impl.QueryRoomVersionForRoom(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("QueryRoomVersionForRoom req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) SetRoomAlias(
	ctx context.Context,
	req *SetRoomAliasRequest,
	res *SetRoomAliasResponse,
) error {
	err := t.Impl.SetRoomAlias(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("SetRoomAlias req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) GetRoomIDForAlias(
	ctx context.Context,
	req *GetRoomIDForAliasRequest,
	res *GetRoomIDForAliasResponse,
) error {
	err := t.Impl.GetRoomIDForAlias(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("GetRoomIDForAlias req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) GetAliasesForRoomID(
	ctx context.Context,
	req *GetAliasesForRoomIDRequest,
	res *GetAliasesForRoomIDResponse,
) error {
	err := t.Impl.GetAliasesForRoomID(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("GetAliasesForRoomID req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) GetCreatorIDForAlias(
	ctx context.Context,
	req *GetCreatorIDForAliasRequest,
	res *GetCreatorIDForAliasResponse,
) error {
	err := t.Impl.GetCreatorIDForAlias(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("GetCreatorIDForAlias req=%+v res=%+v", js(req), js(res))
	return err
}

func (t *RoomserverInternalAPITrace) RemoveRoomAlias(
	ctx context.Context,
	req *RemoveRoomAliasRequest,
	res *RemoveRoomAliasResponse,
) error {
	err := t.Impl.RemoveRoomAlias(ctx, req, res)
	util.GetLogger(ctx).WithError(err).Infof("RemoveRoomAlias req=%+v res=%+v", js(req), js(res))
	return err
}

func js(thing interface{}) string {
	b, err := json.Marshal(thing)
	if err != nil {
		return fmt.Sprintf("Marshal error:%s", err)
	}
	return string(b)
}