Add missing files

This commit is contained in:
Till Faelligen 2021-07-28 16:52:04 +02:00
parent f759107604
commit bf8211b654
6 changed files with 25 additions and 18 deletions

View file

@ -20,6 +20,7 @@ package api
import (
"context"
"github.com/matrix-org/dendrite/userapi/types"
"github.com/matrix-org/gomatrixserverlib"
)
@ -77,10 +78,10 @@ type InputReceiptEventResponse struct{}
// InputPresenceRequest is a request to EDUServerInputAPI
type InputPresenceRequest struct {
UserID string `json:"user_id"`
Status string `json:"status"`
StatusMsg string `json:"status_msg"`
Timestamp gomatrixserverlib.Timestamp `json:"timestamp"`
UserID string `json:"user_id"`
Presence types.PresenceStatus `json:"status"`
StatusMsg string `json:"status_msg"`
LastActiveTS gomatrixserverlib.Timestamp `json:"timestamp"`
}
// InputPresenceResponse is a response to InputPresenceRequest

View file

@ -19,6 +19,7 @@ package api
import (
"time"
"github.com/matrix-org/dendrite/userapi/types"
"github.com/matrix-org/gomatrixserverlib"
)
@ -88,8 +89,9 @@ type FederationReceiptData struct {
// OutputPresence is an entry in the presence output kafka log
type OutputPresence struct {
UserID string `json:"user_id"`
Status string `json:"status"`
StatusMsg string `json:"status_msg"`
Timestamp gomatrixserverlib.Timestamp `json:"timestamp"`
UserID string `json:"user_id"`
Presence types.PresenceStatus `json:"presence"`
StatusMsg string `json:"status_msg,omitempty"`
LastActiveTS gomatrixserverlib.Timestamp `json:"-"`
LastActiveAgo int64 `json:"last_active_ago,omitempty"`
}

View file

@ -19,6 +19,7 @@ import (
"encoding/json"
"time"
"github.com/matrix-org/dendrite/userapi/types"
"github.com/matrix-org/gomatrixserverlib"
)
@ -91,14 +92,15 @@ func SendReceipt(
func SetPresence(
ctx context.Context,
eduAPI EDUServerInputAPI,
userID, status, statusMsg string,
userID, statusMsg string,
presence types.PresenceStatus,
timestamp gomatrixserverlib.Timestamp,
) error {
request := InputPresenceRequest{
UserID: userID,
Status: status,
StatusMsg: statusMsg,
Timestamp: timestamp,
UserID: userID,
Presence: presence,
StatusMsg: statusMsg,
LastActiveTS: timestamp,
}
response := InputPresenceResponse{}
return eduAPI.InputPresence(ctx, &request, &response)

View file

@ -52,6 +52,7 @@ func NewInternalAPI(
OutputTypingEventTopic: cfg.Matrix.Kafka.TopicFor(config.TopicOutputTypingEvent),
OutputSendToDeviceEventTopic: cfg.Matrix.Kafka.TopicFor(config.TopicOutputSendToDeviceEvent),
OutputReceiptEventTopic: cfg.Matrix.Kafka.TopicFor(config.TopicOutputReceiptEvent),
OutputPresenceTopic: cfg.Matrix.Kafka.TopicFor(config.TopicOutputPresenceData),
ServerName: cfg.Matrix.ServerName,
}
}

View file

@ -218,14 +218,14 @@ func (t *EDUServerInputAPI) InputPresence(
) error {
logrus.WithFields(logrus.Fields{
"user_id": request.UserID,
"status": request.Status,
"status": request.Presence,
"status_msg": request.StatusMsg,
}).Infof("Producing to topic '%s'", t.OutputPresenceTopic)
output := &api.OutputPresence{
UserID: request.UserID,
Status: request.Status,
StatusMsg: request.StatusMsg,
Timestamp: request.Timestamp,
UserID: request.UserID,
Presence: request.Presence,
StatusMsg: request.StatusMsg,
LastActiveTS: request.LastActiveTS,
}
js, err := json.Marshal(output)
if err != nil {

View file

@ -10,6 +10,7 @@ const (
TopicOutputRoomEvent = "OutputRoomEvent"
TopicOutputClientData = "OutputClientData"
TopicOutputReceiptEvent = "OutputReceiptEvent"
TopicOutputPresenceData = "OutputPresenceData"
)
type Kafka struct {