예제 #1
0
func (self *Notification) Put(request *gottp.Request) {
	sent_item := new(db.SentItem)
	_id := request.GetArgument("_id").(string)

	if !bson.IsObjectIdHex(_id) {
		request.Raise(gottp.HttpError{http.StatusBadRequest,
			"_id is not a valid Hex object."})
		return
	}

	sent_item.Id = bson.ObjectIdHex(_id)

	err := sentApi.Update(sent_item.Id, &utils.M{"is_read": true})

	if err != nil {
		log.Println(err)
		request.Raise(gottp.HttpError{http.StatusInternalServerError,
			"Unable to insert."})
		return
	}

	request.Write(utils.R{StatusCode: http.StatusNoContent, Data: nil,
		Message: "NoContent"})
	return
}
예제 #2
0
파일: web.go 프로젝트: gitter-badger/khabar
func webHandler(item *db.PendingItem, text string,
	settings map[string]interface{}) {

	sent_item := db.SentItem{
		CreatedBy:      item.CreatedBy,
		AppName:        item.AppName,
		Organization:   item.Organization,
		User:           item.User,
		IsRead:         false,
		Topic:          item.Topic,
		DestinationUri: item.DestinationUri,
		Text:           text,
		Context:        item.Context,
		Entity:         item.Entity,
	}

	sent_item.PrepareSave()
	sent.Insert(&sent_item)
}