Add presence to eduserver

This commit is contained in:
Till Faelligen 2021-06-18 20:51:14 +02:00
parent ebdae1f0c1
commit 2ae8084fd3
3 changed files with 42 additions and 0 deletions

View file

@ -75,6 +75,17 @@ type InputReceiptEventRequest struct {
// InputReceiptEventResponse is a response to InputReceiptEventRequest
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"`
}
// InputPresenceResponse is a response to InputPresenceRequest
type InputPresenceResponse struct{}
// EDUServerInputAPI is used to write events to the typing server.
type EDUServerInputAPI interface {
InputTypingEvent(
@ -94,4 +105,10 @@ type EDUServerInputAPI interface {
request *InputReceiptEventRequest,
response *InputReceiptEventResponse,
) error
InputPresence(
ctx context.Context,
request *InputPresenceRequest,
response *InputPresenceResponse,
) error
}

View file

@ -85,3 +85,11 @@ type FederationReceiptData struct {
Data ReceiptTS `json:"data"`
EventIDs []string `json:"event_ids"`
}
// 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"`
}

View file

@ -86,3 +86,20 @@ func SendReceipt(
response := InputReceiptEventResponse{}
return eduAPI.InputReceiptEvent(ctx, &request, &response)
}
// SetPresence sends a presence change to the EDU Server
func SetPresence(
ctx context.Context,
eduAPI EDUServerInputAPI,
userID, status, statusMsg string,
timestamp gomatrixserverlib.Timestamp,
) error {
request := InputPresenceRequest{
UserID: userID,
Status: status,
StatusMsg: statusMsg,
Timestamp: timestamp,
}
response := InputPresenceResponse{}
return eduAPI.InputPresence(ctx, &request, &response)
}