2019-06-17 11:27:31 +02:00
|
|
|
// gomuks - A terminal Matrix client written in Go.
|
|
|
|
// Copyright (C) 2019 Tulir Asokan
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2020-04-16 18:27:35 +02:00
|
|
|
package muksevt
|
2019-06-17 11:27:31 +02:00
|
|
|
|
|
|
|
import (
|
2020-04-16 18:27:35 +02:00
|
|
|
"maunium.net/go/mautrix/event"
|
2019-06-17 11:27:31 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Event struct {
|
2020-04-16 18:27:35 +02:00
|
|
|
*event.Event
|
2019-06-17 11:27:31 +02:00
|
|
|
Gomuks GomuksContent `json:"-"`
|
|
|
|
}
|
|
|
|
|
2020-02-19 00:14:02 +01:00
|
|
|
func (evt *Event) SomewhatDangerousCopy() *Event {
|
|
|
|
base := *evt.Event
|
2020-04-19 14:00:49 +02:00
|
|
|
content := *base.Content.Parsed.(*event.MessageEventContent)
|
|
|
|
evt.Content.Parsed = &content
|
2020-02-19 00:14:02 +01:00
|
|
|
return &Event{
|
2020-04-19 14:00:49 +02:00
|
|
|
Event: &base,
|
2020-02-19 00:14:02 +01:00
|
|
|
Gomuks: evt.Gomuks,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-16 18:27:35 +02:00
|
|
|
func Wrap(event *event.Event) *Event {
|
2019-06-17 11:27:31 +02:00
|
|
|
return &Event{Event: event}
|
|
|
|
}
|
|
|
|
|
|
|
|
type OutgoingState int
|
|
|
|
|
|
|
|
const (
|
|
|
|
StateDefault OutgoingState = iota
|
|
|
|
StateLocalEcho
|
|
|
|
StateSendFail
|
|
|
|
)
|
|
|
|
|
|
|
|
type GomuksContent struct {
|
|
|
|
OutgoingState OutgoingState
|
|
|
|
Edits []*Event
|
|
|
|
}
|