Implement sending redactions
This commit is contained in:
parent
5ea77a6c5f
commit
c829e436e4
@ -42,6 +42,7 @@ type MatrixContainer interface {
|
|||||||
SendPreferencesToMatrix()
|
SendPreferencesToMatrix()
|
||||||
PrepareMarkdownMessage(roomID string, msgtype mautrix.MessageType, message string, relation *Relation) *event.Event
|
PrepareMarkdownMessage(roomID string, msgtype mautrix.MessageType, message string, relation *Relation) *event.Event
|
||||||
SendEvent(evt *event.Event) (string, error)
|
SendEvent(evt *event.Event) (string, error)
|
||||||
|
Redact(roomID, eventID, reason string) error
|
||||||
SendTyping(roomID string, typing bool)
|
SendTyping(roomID string, typing bool)
|
||||||
MarkRead(roomID, eventID string)
|
MarkRead(roomID, eventID string)
|
||||||
JoinRoom(roomID, server string) (*rooms.Room, error)
|
JoinRoom(roomID, server string) (*rooms.Room, error)
|
||||||
|
@ -768,7 +768,13 @@ func (c *Container) PrepareMarkdownMessage(roomID string, msgtype mautrix.Messag
|
|||||||
return localEcho
|
return localEcho
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMarkdownMessage sends a message with the given markdown text to the given room.
|
func (c *Container) Redact(roomID, eventID, reason string) error {
|
||||||
|
defer debug.Recover()
|
||||||
|
_, err := c.client.RedactEvent(roomID, eventID, mautrix.ReqRedact{Reason: reason})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMessage sends the given event.
|
||||||
func (c *Container) SendEvent(event *event.Event) (string, error) {
|
func (c *Container) SendEvent(event *event.Event) (string, error) {
|
||||||
defer debug.Recover()
|
defer debug.Recover()
|
||||||
|
|
||||||
|
@ -151,10 +151,7 @@ func cmdReply(cmd *Command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cmdRedact(cmd *Command) {
|
func cmdRedact(cmd *Command) {
|
||||||
cmd.Reply("Not yet implemented 3:")
|
cmd.Room.StartSelecting(SelectRedact, strings.Join(cmd.Args, " "))
|
||||||
|
|
||||||
// This needs to be implemented in RoomView's OnSelect method
|
|
||||||
//cmd.Room.StartSelecting(SelectRedact, "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdReact(cmd *Command) {
|
func cmdReact(cmd *Command) {
|
||||||
|
@ -190,7 +190,7 @@ func (view *RoomView) OnSelect(message *messages.UIMessage) {
|
|||||||
case SelectReact:
|
case SelectReact:
|
||||||
go view.SendReaction(message.EventID, view.selectContent)
|
go view.SendReaction(message.EventID, view.selectContent)
|
||||||
case SelectRedact:
|
case SelectRedact:
|
||||||
// TODO redact
|
go view.Redact(message.EventID, view.selectContent)
|
||||||
}
|
}
|
||||||
view.selecting = false
|
view.selecting = false
|
||||||
view.selectContent = ""
|
view.selectContent = ""
|
||||||
@ -580,6 +580,21 @@ func (view *RoomView) InputSubmit(text string) {
|
|||||||
view.SetInputText("")
|
view.SetInputText("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (view *RoomView) Redact(eventID, reason string) {
|
||||||
|
defer debug.Recover()
|
||||||
|
err := view.parent.matrix.Redact(view.Room.ID, eventID, reason)
|
||||||
|
if err != nil {
|
||||||
|
if httpErr, ok := err.(mautrix.HTTPError); ok {
|
||||||
|
err = httpErr
|
||||||
|
if respErr := httpErr.RespError; respErr != nil {
|
||||||
|
err = respErr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
view.AddServiceMessage(fmt.Sprintf("Failed to redact message: %v", err))
|
||||||
|
view.parent.parent.Render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (view *RoomView) SendReaction(eventID string, reaction string) {
|
func (view *RoomView) SendReaction(eventID string, reaction string) {
|
||||||
defer debug.Recover()
|
defer debug.Recover()
|
||||||
debug.Print("Reacting to", eventID, "in", view.Room.ID, "with", reaction)
|
debug.Print("Reacting to", eventID, "in", view.Room.ID, "with", reaction)
|
||||||
|
Loading…
Reference in New Issue
Block a user