2020-05-01 10:48:17 +01:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
2020-09-02 13:47:31 +01:00
|
|
|
"context"
|
2023-06-13 13:19:31 +01:00
|
|
|
"crypto/ed25519"
|
2020-05-01 10:48:17 +01:00
|
|
|
|
2021-03-24 10:25:24 +00:00
|
|
|
"github.com/getsentry/sentry-go"
|
2022-12-22 12:05:59 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2023-06-28 19:29:49 +01:00
|
|
|
"github.com/matrix-org/gomatrixserverlib/fclient"
|
2023-04-19 15:50:33 +01:00
|
|
|
"github.com/matrix-org/gomatrixserverlib/spec"
|
2023-05-31 16:27:08 +01:00
|
|
|
"github.com/matrix-org/util"
|
2022-12-22 12:05:59 +00:00
|
|
|
"github.com/nats-io/nats.go"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
|
2020-12-18 13:33:28 +00:00
|
|
|
asAPI "github.com/matrix-org/dendrite/appservice/api"
|
2021-11-24 10:45:23 +00:00
|
|
|
fsAPI "github.com/matrix-org/dendrite/federationapi/api"
|
2020-05-21 14:40:13 +01:00
|
|
|
"github.com/matrix-org/dendrite/internal/caching"
|
2020-09-03 17:20:54 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/acls"
|
2020-09-02 13:47:31 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/api"
|
2020-09-02 17:13:15 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/internal/input"
|
2020-09-02 13:47:31 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/internal/perform"
|
2020-09-02 17:13:15 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/internal/query"
|
2022-07-01 10:54:07 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/producers"
|
2020-05-01 10:48:17 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/storage"
|
2023-05-31 17:33:49 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
2020-12-02 17:41:00 +00:00
|
|
|
"github.com/matrix-org/dendrite/setup/config"
|
2022-07-01 10:54:07 +01:00
|
|
|
"github.com/matrix-org/dendrite/setup/jetstream"
|
2022-02-17 15:58:54 +00:00
|
|
|
"github.com/matrix-org/dendrite/setup/process"
|
2022-02-18 15:05:03 +00:00
|
|
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
2020-05-01 10:48:17 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// RoomserverInternalAPI is an implementation of api.RoomserverInternalAPI
|
|
|
|
type RoomserverInternalAPI struct {
|
2020-09-02 17:13:15 +01:00
|
|
|
*input.Inputer
|
|
|
|
*query.Queryer
|
|
|
|
*perform.Inviter
|
|
|
|
*perform.Joiner
|
2020-09-10 14:39:18 +01:00
|
|
|
*perform.Peeker
|
2021-01-22 14:55:08 +00:00
|
|
|
*perform.InboundPeeker
|
2020-12-03 11:11:46 +00:00
|
|
|
*perform.Unpeeker
|
2020-09-02 17:13:15 +01:00
|
|
|
*perform.Leaver
|
|
|
|
*perform.Publisher
|
|
|
|
*perform.Backfiller
|
2020-11-05 10:19:23 +00:00
|
|
|
*perform.Forgetter
|
2022-04-05 10:04:08 +01:00
|
|
|
*perform.Upgrader
|
2022-04-28 16:02:30 +01:00
|
|
|
*perform.Admin
|
2023-05-31 16:27:08 +01:00
|
|
|
*perform.Creator
|
2022-02-17 15:58:54 +00:00
|
|
|
ProcessContext *process.ProcessContext
|
2020-10-06 18:09:02 +01:00
|
|
|
DB storage.Database
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg *config.Dendrite
|
2020-10-06 18:09:02 +01:00
|
|
|
Cache caching.RoomServerCaches
|
2023-04-19 15:50:33 +01:00
|
|
|
ServerName spec.ServerName
|
2020-10-06 18:09:02 +01:00
|
|
|
KeyRing gomatrixserverlib.JSONVerifier
|
2022-01-27 14:29:14 +00:00
|
|
|
ServerACLs *acls.ServerACLs
|
2022-05-05 19:30:38 +01:00
|
|
|
fsAPI fsAPI.RoomserverFederationAPI
|
2022-05-06 12:39:26 +01:00
|
|
|
asAPI asAPI.AppServiceInternalAPI
|
2022-03-16 14:21:11 +00:00
|
|
|
NATSClient *nats.Conn
|
2022-01-27 14:29:14 +00:00
|
|
|
JetStream nats.JetStreamContext
|
2022-02-02 13:32:48 +00:00
|
|
|
Durable string
|
2022-01-05 17:44:49 +00:00
|
|
|
InputRoomEventTopic string // JetStream topic for new input room events
|
2022-07-01 10:54:07 +01:00
|
|
|
OutputProducer *producers.RoomEventProducer
|
2023-04-19 15:50:33 +01:00
|
|
|
PerspectiveServerNames []spec.ServerName
|
2023-03-22 08:21:32 +00:00
|
|
|
enableMetrics bool
|
2023-08-08 14:20:05 +01:00
|
|
|
defaultRoomVersion gomatrixserverlib.RoomVersion
|
2020-05-01 10:48:17 +01:00
|
|
|
}
|
2020-09-02 13:47:31 +01:00
|
|
|
|
|
|
|
func NewRoomserverAPI(
|
2023-03-22 08:21:32 +00:00
|
|
|
processContext *process.ProcessContext, dendriteCfg *config.Dendrite, roomserverDB storage.Database,
|
|
|
|
js nats.JetStreamContext, nc *nats.Conn, caches caching.RoomServerCaches, enableMetrics bool,
|
2020-09-02 13:47:31 +01:00
|
|
|
) *RoomserverInternalAPI {
|
2023-04-19 15:50:33 +01:00
|
|
|
var perspectiveServerNames []spec.ServerName
|
2023-03-22 08:21:32 +00:00
|
|
|
for _, kp := range dendriteCfg.FederationAPI.KeyPerspectives {
|
2022-07-05 13:50:56 +01:00
|
|
|
perspectiveServerNames = append(perspectiveServerNames, kp.ServerName)
|
|
|
|
}
|
|
|
|
|
2020-09-04 10:40:58 +01:00
|
|
|
serverACLs := acls.NewServerACLs(roomserverDB)
|
2022-07-01 10:54:07 +01:00
|
|
|
producer := &producers.RoomEventProducer{
|
2023-03-22 08:21:32 +00:00
|
|
|
Topic: string(dendriteCfg.Global.JetStream.Prefixed(jetstream.OutputRoomEvent)),
|
2022-07-01 10:54:07 +01:00
|
|
|
JetStream: js,
|
|
|
|
ACLs: serverACLs,
|
|
|
|
}
|
2020-09-02 13:47:31 +01:00
|
|
|
a := &RoomserverInternalAPI{
|
2023-03-22 08:21:32 +00:00
|
|
|
ProcessContext: processContext,
|
2020-10-06 18:09:02 +01:00
|
|
|
DB: roomserverDB,
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: dendriteCfg,
|
2023-03-17 11:09:45 +00:00
|
|
|
Cache: caches,
|
2023-03-22 08:21:32 +00:00
|
|
|
ServerName: dendriteCfg.Global.ServerName,
|
2020-10-06 18:09:02 +01:00
|
|
|
PerspectiveServerNames: perspectiveServerNames,
|
2023-03-22 08:21:32 +00:00
|
|
|
InputRoomEventTopic: dendriteCfg.Global.JetStream.Prefixed(jetstream.InputRoomEvent),
|
2022-07-01 10:54:07 +01:00
|
|
|
OutputProducer: producer,
|
|
|
|
JetStream: js,
|
2022-03-16 14:21:11 +00:00
|
|
|
NATSClient: nc,
|
2023-03-22 08:21:32 +00:00
|
|
|
Durable: dendriteCfg.Global.JetStream.Durable("RoomserverInputConsumer"),
|
2022-01-27 14:29:14 +00:00
|
|
|
ServerACLs: serverACLs,
|
2023-07-20 15:06:05 +01:00
|
|
|
enableMetrics: enableMetrics,
|
2023-08-08 14:20:05 +01:00
|
|
|
defaultRoomVersion: dendriteCfg.RoomServer.DefaultRoomVersion,
|
2023-07-20 15:06:05 +01:00
|
|
|
// perform-er structs + queryer struct get initialised when we have a federation sender to use
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
// SetFederationInputAPI passes in a federation input API reference so that we can
|
|
|
|
// avoid the chicken-and-egg problem of both the roomserver input API and the
|
|
|
|
// federation input API being interdependent.
|
2022-05-05 19:30:38 +01:00
|
|
|
func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederationAPI, keyRing *gomatrixserverlib.KeyRing) {
|
2020-09-02 13:47:31 +01:00
|
|
|
r.fsAPI = fsAPI
|
2021-12-13 13:24:49 +00:00
|
|
|
r.KeyRing = keyRing
|
2020-09-02 13:47:31 +01:00
|
|
|
|
2023-07-20 15:06:05 +01:00
|
|
|
r.Queryer = &query.Queryer{
|
|
|
|
DB: r.DB,
|
|
|
|
Cache: r.Cache,
|
|
|
|
IsLocalServerName: r.Cfg.Global.IsLocalServerName,
|
|
|
|
ServerACLs: r.ServerACLs,
|
|
|
|
Cfg: r.Cfg,
|
|
|
|
FSAPI: fsAPI,
|
|
|
|
}
|
|
|
|
|
2022-01-27 14:29:14 +00:00
|
|
|
r.Inputer = &input.Inputer{
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
|
|
|
ProcessContext: r.ProcessContext,
|
2022-07-01 10:54:07 +01:00
|
|
|
DB: r.DB,
|
|
|
|
InputRoomEventTopic: r.InputRoomEventTopic,
|
|
|
|
OutputProducer: r.OutputProducer,
|
|
|
|
JetStream: r.JetStream,
|
|
|
|
NATSClient: r.NATSClient,
|
|
|
|
Durable: nats.Durable(r.Durable),
|
2022-12-22 12:05:59 +00:00
|
|
|
ServerName: r.ServerName,
|
2023-06-28 19:29:49 +01:00
|
|
|
SigningIdentity: r.SigningIdentityFor,
|
2022-07-01 10:54:07 +01:00
|
|
|
FSAPI: fsAPI,
|
2023-07-21 17:08:40 +01:00
|
|
|
RSAPI: r,
|
2022-07-01 10:54:07 +01:00
|
|
|
KeyRing: keyRing,
|
|
|
|
ACLs: r.ServerACLs,
|
|
|
|
Queryer: r.Queryer,
|
2023-07-05 11:34:53 +01:00
|
|
|
EnableMetrics: r.enableMetrics,
|
2022-01-27 14:29:14 +00:00
|
|
|
}
|
2020-09-02 13:47:31 +01:00
|
|
|
r.Inviter = &perform.Inviter{
|
2020-09-02 17:13:15 +01:00
|
|
|
DB: r.DB,
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
2020-09-02 17:13:15 +01:00
|
|
|
FSAPI: r.fsAPI,
|
2023-05-31 17:33:49 +01:00
|
|
|
RSAPI: r,
|
2020-09-02 17:13:15 +01:00
|
|
|
Inputer: r.Inputer,
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
|
|
|
r.Joiner = &perform.Joiner{
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
2022-11-15 15:05:23 +00:00
|
|
|
DB: r.DB,
|
|
|
|
FSAPI: r.fsAPI,
|
|
|
|
RSAPI: r,
|
|
|
|
Inputer: r.Inputer,
|
|
|
|
Queryer: r.Queryer,
|
2020-09-10 14:39:18 +01:00
|
|
|
}
|
|
|
|
r.Peeker = &perform.Peeker{
|
2022-12-22 12:05:59 +00:00
|
|
|
ServerName: r.ServerName,
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
2020-09-10 14:39:18 +01:00
|
|
|
DB: r.DB,
|
|
|
|
FSAPI: r.fsAPI,
|
2020-09-02 17:13:15 +01:00
|
|
|
Inputer: r.Inputer,
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
2021-01-22 14:55:08 +00:00
|
|
|
r.InboundPeeker = &perform.InboundPeeker{
|
|
|
|
DB: r.DB,
|
|
|
|
Inputer: r.Inputer,
|
|
|
|
}
|
2020-12-03 11:11:46 +00:00
|
|
|
r.Unpeeker = &perform.Unpeeker{
|
2022-12-22 12:05:59 +00:00
|
|
|
ServerName: r.ServerName,
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
2020-12-03 11:11:46 +00:00
|
|
|
FSAPI: r.fsAPI,
|
|
|
|
Inputer: r.Inputer,
|
|
|
|
}
|
2020-09-02 13:47:31 +01:00
|
|
|
r.Leaver = &perform.Leaver{
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
2020-09-02 17:13:15 +01:00
|
|
|
DB: r.DB,
|
|
|
|
FSAPI: r.fsAPI,
|
2023-04-14 16:03:07 +01:00
|
|
|
RSAPI: r,
|
2020-09-02 17:13:15 +01:00
|
|
|
Inputer: r.Inputer,
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
|
|
|
r.Publisher = &perform.Publisher{
|
|
|
|
DB: r.DB,
|
|
|
|
}
|
|
|
|
r.Backfiller = &perform.Backfiller{
|
2023-03-22 08:21:32 +00:00
|
|
|
IsLocalServerName: r.Cfg.Global.IsLocalServerName,
|
2022-11-15 15:05:23 +00:00
|
|
|
DB: r.DB,
|
|
|
|
FSAPI: r.fsAPI,
|
2023-06-14 15:23:46 +01:00
|
|
|
Querier: r.Queryer,
|
2022-11-15 15:05:23 +00:00
|
|
|
KeyRing: r.KeyRing,
|
2020-10-06 18:09:02 +01:00
|
|
|
// Perspective servers are trusted to not lie about server keys, so we will also
|
|
|
|
// prefer these servers when backfilling (assuming they are in the room) rather
|
|
|
|
// than trying random servers
|
|
|
|
PreferServers: r.PerspectiveServerNames,
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
2020-11-05 10:19:23 +00:00
|
|
|
r.Forgetter = &perform.Forgetter{
|
|
|
|
DB: r.DB,
|
|
|
|
}
|
2022-04-05 10:04:08 +01:00
|
|
|
r.Upgrader = &perform.Upgrader{
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
2022-04-05 10:04:08 +01:00
|
|
|
URSAPI: r,
|
|
|
|
}
|
2022-04-28 16:02:30 +01:00
|
|
|
r.Admin = &perform.Admin{
|
|
|
|
DB: r.DB,
|
2023-03-22 08:21:32 +00:00
|
|
|
Cfg: &r.Cfg.RoomServer,
|
2022-04-28 16:02:30 +01:00
|
|
|
Inputer: r.Inputer,
|
|
|
|
Queryer: r.Queryer,
|
2022-06-29 15:29:39 +01:00
|
|
|
Leaver: r.Leaver,
|
2022-04-28 16:02:30 +01:00
|
|
|
}
|
2023-05-31 16:27:08 +01:00
|
|
|
r.Creator = &perform.Creator{
|
|
|
|
DB: r.DB,
|
|
|
|
Cfg: &r.Cfg.RoomServer,
|
|
|
|
RSAPI: r,
|
|
|
|
}
|
2022-01-07 13:41:53 +00:00
|
|
|
|
|
|
|
if err := r.Inputer.Start(); err != nil {
|
|
|
|
logrus.WithError(err).Panic("failed to start roomserver input API")
|
|
|
|
}
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
|
|
|
|
2022-05-06 12:39:26 +01:00
|
|
|
func (r *RoomserverInternalAPI) SetUserAPI(userAPI userapi.RoomserverUserAPI) {
|
2022-02-18 15:05:03 +00:00
|
|
|
r.Leaver.UserAPI = userAPI
|
2022-12-22 12:05:59 +00:00
|
|
|
r.Inputer.UserAPI = userAPI
|
2022-02-18 15:05:03 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 12:39:26 +01:00
|
|
|
func (r *RoomserverInternalAPI) SetAppserviceAPI(asAPI asAPI.AppServiceInternalAPI) {
|
2020-12-18 13:33:28 +00:00
|
|
|
r.asAPI = asAPI
|
|
|
|
}
|
|
|
|
|
2023-08-08 14:20:05 +01:00
|
|
|
func (r *RoomserverInternalAPI) DefaultRoomVersion() gomatrixserverlib.RoomVersion {
|
|
|
|
return r.defaultRoomVersion
|
|
|
|
}
|
|
|
|
|
2023-05-31 17:33:49 +01:00
|
|
|
func (r *RoomserverInternalAPI) IsKnownRoom(ctx context.Context, roomID spec.RoomID) (bool, error) {
|
|
|
|
return r.Inviter.IsKnownRoom(ctx, roomID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RoomserverInternalAPI) StateQuerier() gomatrixserverlib.StateQuerier {
|
|
|
|
return r.Inviter.StateQuerier()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RoomserverInternalAPI) HandleInvite(
|
|
|
|
ctx context.Context, inviteEvent *types.HeaderedEvent,
|
|
|
|
) error {
|
|
|
|
outputEvents, err := r.Inviter.ProcessInviteMembership(ctx, inviteEvent)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-09-15 15:39:06 +01:00
|
|
|
return r.OutputProducer.ProduceRoomEvents(inviteEvent.RoomID().String(), outputEvents)
|
2023-05-31 17:33:49 +01:00
|
|
|
}
|
|
|
|
|
2023-05-31 16:27:08 +01:00
|
|
|
func (r *RoomserverInternalAPI) PerformCreateRoom(
|
|
|
|
ctx context.Context, userID spec.UserID, roomID spec.RoomID, createRequest *api.PerformCreateRoomRequest,
|
|
|
|
) (string, *util.JSONResponse) {
|
|
|
|
return r.Creator.PerformCreateRoom(ctx, userID, roomID, createRequest)
|
|
|
|
}
|
|
|
|
|
2020-09-02 13:47:31 +01:00
|
|
|
func (r *RoomserverInternalAPI) PerformInvite(
|
|
|
|
ctx context.Context,
|
|
|
|
req *api.PerformInviteRequest,
|
|
|
|
) error {
|
2023-05-31 17:33:49 +01:00
|
|
|
return r.Inviter.PerformInvite(ctx, req)
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RoomserverInternalAPI) PerformLeave(
|
|
|
|
ctx context.Context,
|
|
|
|
req *api.PerformLeaveRequest,
|
|
|
|
res *api.PerformLeaveResponse,
|
|
|
|
) error {
|
|
|
|
outputEvents, err := r.Leaver.PerformLeave(ctx, req, res)
|
|
|
|
if err != nil {
|
2021-03-24 10:25:24 +00:00
|
|
|
sentry.CaptureException(err)
|
2020-09-02 13:47:31 +01:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
if len(outputEvents) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
2022-07-01 10:54:07 +01:00
|
|
|
return r.OutputProducer.ProduceRoomEvents(req.RoomID, outputEvents)
|
2020-09-02 13:47:31 +01:00
|
|
|
}
|
2020-11-05 10:19:23 +00:00
|
|
|
|
|
|
|
func (r *RoomserverInternalAPI) PerformForget(
|
|
|
|
ctx context.Context,
|
|
|
|
req *api.PerformForgetRequest,
|
|
|
|
resp *api.PerformForgetResponse,
|
|
|
|
) error {
|
|
|
|
return r.Forgetter.PerformForget(ctx, req, resp)
|
|
|
|
}
|
2023-06-13 13:19:31 +01:00
|
|
|
|
|
|
|
// GetOrCreateUserRoomPrivateKey gets the user room key for the specified user. If no key exists yet, a new one is created.
|
|
|
|
func (r *RoomserverInternalAPI) GetOrCreateUserRoomPrivateKey(ctx context.Context, userID spec.UserID, roomID spec.RoomID) (ed25519.PrivateKey, error) {
|
|
|
|
key, err := r.DB.SelectUserRoomPrivateKey(ctx, userID, roomID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
// no key found, create one
|
|
|
|
if len(key) == 0 {
|
|
|
|
_, key, err = ed25519.GenerateKey(nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
key, err = r.DB.InsertUserRoomPrivatePublicKey(ctx, userID, roomID, key)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return key, nil
|
|
|
|
}
|
2023-06-28 19:29:49 +01:00
|
|
|
|
|
|
|
func (r *RoomserverInternalAPI) StoreUserRoomPublicKey(ctx context.Context, senderID spec.SenderID, userID spec.UserID, roomID spec.RoomID) error {
|
|
|
|
pubKeyBytes, err := senderID.RawBytes()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = r.DB.InsertUserRoomPublicKey(ctx, userID, roomID, ed25519.PublicKey(pubKeyBytes))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RoomserverInternalAPI) SigningIdentityFor(ctx context.Context, roomID spec.RoomID, senderID spec.UserID) (fclient.SigningIdentity, error) {
|
|
|
|
roomVersion, ok := r.Cache.GetRoomVersion(roomID.String())
|
|
|
|
if !ok {
|
|
|
|
roomInfo, err := r.DB.RoomInfo(ctx, roomID.String())
|
|
|
|
if err != nil {
|
|
|
|
return fclient.SigningIdentity{}, err
|
|
|
|
}
|
|
|
|
if roomInfo != nil {
|
|
|
|
roomVersion = roomInfo.RoomVersion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if roomVersion == gomatrixserverlib.RoomVersionPseudoIDs {
|
|
|
|
privKey, err := r.GetOrCreateUserRoomPrivateKey(ctx, senderID, roomID)
|
|
|
|
if err != nil {
|
|
|
|
return fclient.SigningIdentity{}, err
|
|
|
|
}
|
|
|
|
return fclient.SigningIdentity{
|
|
|
|
PrivateKey: privKey,
|
|
|
|
KeyID: "ed25519:1",
|
2023-07-06 16:15:24 +01:00
|
|
|
ServerName: spec.ServerName(spec.SenderIDFromPseudoIDKey(privKey)),
|
2023-06-28 19:29:49 +01:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
identity, err := r.Cfg.Global.SigningIdentityFor(senderID.Domain())
|
|
|
|
if err != nil {
|
|
|
|
return fclient.SigningIdentity{}, err
|
|
|
|
}
|
|
|
|
return *identity, err
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2024-03-21 18:27:34 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|