import ( "fmt" "net/http" "time" "github.com/gorilla/mux" "github.com/gorilla/sessions" "github.com/nathanborror/gommon/auth" "github.com/nathanborror/gommon/crypto" "github.com/nathanborror/gommon/render" "github.com/nathanborror/spaces/dropbox" ) var repo = RoomSQLRepository("db.sqlite3") var roomMemberRepo = RoomMemberSQLRepository("db.sqlite3") var userRepo = auth.AuthSQLRepository("db.sqlite3") var cookieStore = sessions.NewCookieStore([]byte("something-very-very-secret")) // SaveHandler saves a item func SaveHandler(w http.ResponseWriter, r *http.Request) { u, _ := auth.GetAuthenticatedUser(r) hash := r.FormValue("hash") name := r.FormValue("name") kind := Open folder := r.FormValue("folder") created := time.Now() if hash == "" { hash = crypto.UniqueHash(name) }
package messages import ( "time" "github.com/nathanborror/gommon/auth" ) var authRepo = auth.AuthSQLRepository("db.sqlite3") // MarshalPreparable can supply an alternative value in preparation for marshalling type MarshalPreparable interface { MarshalPrepare() interface{} } // Message defines a message sent from a user type Message struct { Hash string `json:"hash"` Room string `json:"room"` User string `json:"user"` Text string `json:"text"` Created time.Time `json:"created"` Modified time.Time `json:"modified"` } // MessageList returns a list of Messages type MessageList []*Message // MessageAction defines an action thats encoded in the message (e.g. stickers, room events, etc.) type MessageAction struct { Type string `json:"type"`