mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 10:53:09 -06:00
Update OutputTypingEvent format
This commit is contained in:
parent
0bd298ad85
commit
7ae50fffd4
|
|
@ -16,16 +16,14 @@ package api
|
||||||
type OutputTypingEvent struct {
|
type OutputTypingEvent struct {
|
||||||
// The Event for the typing edu event.
|
// The Event for the typing edu event.
|
||||||
Event TypingEvent `json:"event"`
|
Event TypingEvent `json:"event"`
|
||||||
|
// Users typing in the room at the event.
|
||||||
|
TypingUsers []string `json:"typing_users"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypingEvent represents a matrix edu event of type 'm.typing'.
|
// TypingEvent represents a matrix edu event of type 'm.typing'.
|
||||||
type TypingEvent struct {
|
type TypingEvent struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
RoomID string `json:"room_id"`
|
RoomID string `json:"room_id"`
|
||||||
Content TypingEventContent `json:"content"`
|
UserID string `json:"user_id"`
|
||||||
}
|
Typing bool `json:"typing"`
|
||||||
|
|
||||||
// TypingEventContent for TypingEvent
|
|
||||||
type TypingEventContent struct {
|
|
||||||
UserIDs []string `json:"user_ids"`
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,24 +53,29 @@ func (t *TypingServerInputAPI) InputTypingEvent(
|
||||||
t.Cache.RemoveUser(ite.UserID, ite.RoomID)
|
t.Cache.RemoveUser(ite.UserID, ite.RoomID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return t.sendUpdateForRoom(ite.RoomID)
|
return t.sendEvent(ite)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypingServerInputAPI) sendUpdateForRoom(roomID string) error {
|
func (t *TypingServerInputAPI) sendEvent(ite *api.InputTypingEvent) error {
|
||||||
userIDs := t.Cache.GetTypingUsers(roomID)
|
userIDs := t.Cache.GetTypingUsers(ite.RoomID)
|
||||||
event := &api.TypingEvent{
|
ev := &api.TypingEvent{
|
||||||
Type: gomatrixserverlib.MTyping,
|
Type: gomatrixserverlib.MTyping,
|
||||||
RoomID: roomID,
|
RoomID: ite.RoomID,
|
||||||
Content: api.TypingEventContent{UserIDs: userIDs},
|
UserID: ite.UserID,
|
||||||
}
|
}
|
||||||
eventJSON, err := json.Marshal(api.OutputTypingEvent{Event: *event})
|
ote := &api.OutputTypingEvent{
|
||||||
|
Event: *ev,
|
||||||
|
TypingUsers: userIDs,
|
||||||
|
}
|
||||||
|
|
||||||
|
eventJSON, err := json.Marshal(ote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
m := &sarama.ProducerMessage{
|
m := &sarama.ProducerMessage{
|
||||||
Topic: string(t.OutputTypingEventTopic),
|
Topic: string(t.OutputTypingEventTopic),
|
||||||
Key: sarama.StringEncoder(roomID),
|
Key: sarama.StringEncoder(ite.RoomID),
|
||||||
Value: sarama.ByteEncoder(eventJSON),
|
Value: sarama.ByteEncoder(eventJSON),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue