~geb/sup

c2aa982c84ef11ed4603e6e01b3f1a7aab6085f2 — John Gebbie 1 year, 11 months ago 967b87d
pull recent event messages
1 files changed, 15 insertions(+), 3 deletions(-)

M main.go
M main.go => main.go +15 -3
@@ 590,6 590,13 @@ func processMessageEvent(roomID id.RoomID, evt *event.Event) {
	_ = evt.Content.ParseRaw(evt.Type)
}

// based off DefaultSyncer.processSyncEvent
func processStateEvent(roomID id.RoomID, evt *event.Event) {
	evt.RoomID = roomID
	evt.Type.Class = event.StateEventType
	_ = evt.Content.ParseRaw(evt.Type)
}

func (app *App) pullRecentMessages() error {
	var fid string
	{


@@ 597,7 604,7 @@ func (app *App) pullRecentMessages() error {
			Room: mautrix.RoomFilter{
				Timeline: mautrix.FilterPart{
					Limit: 50,
					Types: []event.Type{event.EventMessage},
					Types: []event.Type{event.EventMessage, event.StateMember},
				},
			},
		})


@@ 622,8 629,13 @@ func (app *App) pullRecentMessages() error {

	for rid, room := range resp.Rooms.Join {
		for _, ev := range room.Timeline.Events {
			processMessageEvent(rid, ev)
			app.addMessage(normalMessage(ev))
			if ev.Type == event.EventMessage {
				processMessageEvent(rid, ev)
				app.addMessage(normalMessage(ev))
			} else if ev.Type == event.StateMember {
				processStateEvent(rid, ev)
				app.addMessage(eventMessage(ev))
			}
		}
	}