Use mautrix for tag events instead of deprecated matrix/go

This commit is contained in:
Dario 2024-05-31 22:44:32 +02:00
parent 46902e5766
commit c1171952c6
2 changed files with 8 additions and 8 deletions

View file

@ -21,9 +21,9 @@ import (
"github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/producers" "github.com/matrix-org/dendrite/clientapi/producers"
"github.com/matrix-org/dendrite/userapi/api" "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrix"
"github.com/matrix-org/gomatrixserverlib/spec" "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/matrix-org/util" "github.com/matrix-org/util"
"maunium.net/go/mautrix/event"
) )
// GetTags implements GET /_matrix/client/r0/user/{userID}/rooms/{roomID}/tags // GetTags implements GET /_matrix/client/r0/user/{userID}/rooms/{roomID}/tags
@ -78,7 +78,7 @@ func PutTag(
} }
} }
var properties gomatrix.TagProperties var properties event.Tag
if reqErr := httputil.UnmarshalJSONRequest(req, &properties); reqErr != nil { if reqErr := httputil.UnmarshalJSONRequest(req, &properties); reqErr != nil {
return *reqErr return *reqErr
} }
@ -93,7 +93,7 @@ func PutTag(
} }
if tagContent.Tags == nil { if tagContent.Tags == nil {
tagContent.Tags = make(map[string]gomatrix.TagProperties) tagContent.Tags = make(map[string]event.Tag)
} }
tagContent.Tags[tag] = properties tagContent.Tags[tag] = properties
@ -172,7 +172,7 @@ func obtainSavedTags(
userID string, userID string,
roomID string, roomID string,
userAPI api.ClientUserAPI, userAPI api.ClientUserAPI,
) (tags gomatrix.TagContent, err error) { ) (tags event.TagEventContent, err error) {
dataReq := api.QueryAccountDataRequest{ dataReq := api.QueryAccountDataRequest{
UserID: userID, UserID: userID,
RoomID: roomID, RoomID: roomID,
@ -199,7 +199,7 @@ func saveTagData(
userID string, userID string,
roomID string, roomID string,
userAPI api.ClientUserAPI, userAPI api.ClientUserAPI,
Tag gomatrix.TagContent, Tag event.TagEventContent,
) error { ) error {
newTagData, err := json.Marshal(Tag) newTagData, err := json.Marshal(Tag)
if err != nil { if err != nil {

View file

@ -21,11 +21,11 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/matrix-org/gomatrix"
"github.com/matrix-org/gomatrixserverlib/tokens" "github.com/matrix-org/gomatrixserverlib/tokens"
"github.com/matrix-org/util" "github.com/matrix-org/util"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"maunium.net/go/mautrix/event"
"github.com/matrix-org/dendrite/roomserver/types" "github.com/matrix-org/dendrite/roomserver/types"
@ -176,9 +176,9 @@ func SendServerNotice(
roomID = data.RoomID roomID = data.RoomID
// tag the room, so we can later check if the user tries to reject an invite // tag the room, so we can later check if the user tries to reject an invite
serverAlertTag := gomatrix.TagContent{Tags: map[string]gomatrix.TagProperties{ serverAlertTag := event.TagEventContent{Tags: map[string]event.Tag{
"m.server_notice": { "m.server_notice": {
Order: 1.0, Order: "1.0",
}, },
}} }}
if err = saveTagData(req, r.UserID, roomID, userAPI, serverAlertTag); err != nil { if err = saveTagData(req, r.UserID, roomID, userAPI, serverAlertTag); err != nil {