diff options
Diffstat (limited to 'ui/messages')
-rw-r--r-- | ui/messages/parser/htmlparser.go (renamed from ui/messages/htmlparser.go) | 2 | ||||
-rw-r--r-- | ui/messages/parser/htmltagarray.go (renamed from ui/messages/htmltagarray.go) | 2 | ||||
-rw-r--r-- | ui/messages/parser/parser.go (renamed from ui/messages/parser.go) | 17 |
3 files changed, 11 insertions, 10 deletions
diff --git a/ui/messages/htmlparser.go b/ui/messages/parser/htmlparser.go index aa6211e..cb8f254 100644 --- a/ui/messages/htmlparser.go +++ b/ui/messages/parser/htmlparser.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. -package messages +package parser import ( "fmt" diff --git a/ui/messages/htmltagarray.go b/ui/messages/parser/htmltagarray.go index 597f0c7..4cd4245 100644 --- a/ui/messages/htmltagarray.go +++ b/ui/messages/parser/htmltagarray.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. -package messages +package parser // TagWithMeta is an open HTML tag with some metadata (e.g. list index, a href value). type TagWithMeta struct { diff --git a/ui/messages/parser.go b/ui/messages/parser/parser.go index 80ce5d6..939dd10 100644 --- a/ui/messages/parser.go +++ b/ui/messages/parser/parser.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. -package messages +package parser import ( "fmt" @@ -24,12 +24,13 @@ import ( "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/interface" "maunium.net/go/gomuks/matrix/rooms" + "maunium.net/go/gomuks/ui/messages" "maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/gomuks/ui/widget" "maunium.net/go/tcell" ) -func ParseEvent(gmx ifc.Gomuks, room *rooms.Room, evt *gomatrix.Event) UIMessage { +func ParseEvent(gmx ifc.Gomuks, room *rooms.Room, evt *gomatrix.Event) messages.UIMessage { member := room.GetMember(evt.Sender) if member != nil { evt.Sender = member.DisplayName @@ -51,7 +52,7 @@ func unixToTime(unix int64) time.Time { return timestamp } -func ParseMessage(gmx ifc.Gomuks, room *rooms.Room, evt *gomatrix.Event) UIMessage { +func ParseMessage(gmx ifc.Gomuks, room *rooms.Room, evt *gomatrix.Event) messages.UIMessage { msgtype, _ := evt.Content["msgtype"].(string) ts := unixToTime(evt.Timestamp) switch msgtype { @@ -59,10 +60,10 @@ func ParseMessage(gmx ifc.Gomuks, room *rooms.Room, evt *gomatrix.Event) UIMessa format, hasFormat := evt.Content["format"].(string) if hasFormat && format == "org.matrix.custom.html" { text := ParseHTMLMessage(room, evt) - return NewExpandedTextMessage(evt.ID, evt.Sender, msgtype, text, ts) + return messages.NewExpandedTextMessage(evt.ID, evt.Sender, msgtype, text, ts) } else { text, _ := evt.Content["body"].(string) - return NewTextMessage(evt.ID, evt.Sender, msgtype, text, ts) + return messages.NewTextMessage(evt.ID, evt.Sender, msgtype, text, ts) } case "m.image": url, _ := evt.Content["url"].(string) @@ -70,7 +71,7 @@ func ParseMessage(gmx ifc.Gomuks, room *rooms.Room, evt *gomatrix.Event) UIMessa if err != nil { debug.Printf("Failed to download %s: %v", url, err) } - return NewImageMessage(gmx, evt.ID, evt.Sender, msgtype, hs, id, data, ts) + return messages.NewImageMessage(gmx, evt.ID, evt.Sender, msgtype, hs, id, data, ts) } return nil } @@ -120,8 +121,8 @@ func getMembershipEventContent(evt *gomatrix.Event) (sender string, text tstring return } -func ParseMembershipEvent(evt *gomatrix.Event) UIMessage { +func ParseMembershipEvent(evt *gomatrix.Event) messages.UIMessage { sender, text := getMembershipEventContent(evt) ts := unixToTime(evt.Timestamp) - return NewExpandedTextMessage(evt.ID, sender, "m.room.membership", text, ts) + return messages.NewExpandedTextMessage(evt.ID, sender, "m.room.membership", text, ts) } |