Exemple #1
0
func message(eventId, userId string) *matrixTypes.Message {
	event := matrixTypes.Message{}
	event.EventType = "m.room.create"
	event.Content = matrixTypes.CreateEventContent{types.NewUserId(userId, "test")}
	event.RoomId = types.NewRoomId("room", "test")
	event.Timestamp = types.Timestamp{time.Now()}
	event.EventId = types.NewEventId(eventId, "test")
	return &event
}
Exemple #2
0
func (s roomService) sendMessage(
	room ct.RoomId,
	user ct.UserId,
	content types.TypedContent,
) (*types.Message, types.Error) {
	log.Printf("Sending message: %#v, %#v, %#v, %#v", room, user, content)

	message := new(types.Message)
	message.EventId = ct.DeriveEventId(utils.RandomString(16), ct.Id(user))
	message.RoomId = room
	message.UserId = user
	message.EventType = content.GetEventType()
	message.Timestamp = ct.Timestamp{time.Now()}
	message.Content = content

	_, err := s.eventSink.Send(message)
	if err != nil {
		return nil, err
	}
	return message, nil
}