func NewMessage( room *Room, sessionView *proto.SessionView, id, parent snowflake.Snowflake, keyID, content string) ( *Message, error) { msg := &Message{ Room: room.Name, ID: id.String(), Parent: parent.String(), Posted: id.Time(), Content: content, } if sessionView != nil { msg.SessionID = sessionView.SessionID msg.SenderID = string(sessionView.ID) msg.SenderName = sessionView.Name msg.ServerID = sessionView.ServerID msg.ServerEra = sessionView.ServerEra msg.SenderIsManager = sessionView.IsManager msg.SenderIsStaff = sessionView.IsStaff } if keyID != "" { msg.EncryptionKeyID = sql.NullString{ String: keyID, Valid: true, } } return msg, nil }
func NewMessage( roomName string, sessionView proto.SessionView, id, parent snowflake.Snowflake, keyID, content string) ( *Message, error) { msg := &Message{ Room: roomName, ID: id.String(), Parent: parent.String(), Posted: id.Time(), Content: content, SessionID: sessionView.SessionID, SenderID: string(sessionView.ID), SenderName: sessionView.Name, ServerID: sessionView.ServerID, ServerEra: sessionView.ServerEra, SenderClientAddress: sessionView.ClientAddress, SenderIsManager: sessionView.IsManager, SenderIsStaff: sessionView.IsStaff, } if keyID != "" { msg.EncryptionKeyID = sql.NullString{ String: keyID, Valid: true, } } return msg, nil }