Пример #1
0
func (self *TopicChannel) Post(request *gottp.Request) {
	channelName := request.GetArgument("channel").(string)
	if !core.IsChannelAvailable(channelName) {
		request.Raise(gottp.HttpError{
			http.StatusBadRequest,
			"Channel is not supported",
		})

		return
	}

	topic := new(db.Topic)
	request.ConvertArguments(topic)

	err := topics.InsertOrUpdateTopic(topic.Organization, topic.Ident, channelName, "Enabled", true, topic.User)
	// topics.AddChannel(topic.Ident, channelName, topic.User, topic.Organization)

	if err != nil {
		request.Raise(gottp.HttpError{http.StatusBadRequest, err.Error()})
		return
	}

	request.Write(utils.R{
		Data:       nil,
		Message:    "true",
		StatusCode: http.StatusNoContent,
	})

	return
}
Пример #2
0
func (self *DefaultLocked) Delete(request *gottp.Request) {
	channelName := request.GetArgument("channel").(string)
	ident := request.GetArgument("ident").(string)
	org := request.GetArgument("org").(string)
	defaultOrLocked := getDefaultOrLocked(request)

	if !core.IsChannelAvailable(channelName) {
		request.Raise(gottp.HttpError{
			http.StatusBadRequest,
			"Channel is not supported",
		})

		return
	}

	err := topics.InsertOrUpdateTopic(org, ident, channelName, defaultOrLocked, false, "")

	if err != nil {
		if err != mgo.ErrNotFound {
			request.Raise(gottp.HttpError{http.StatusInternalServerError,
				"Unable to complete db operation."})
			return
		}
	}

	request.Write(utils.R{StatusCode: http.StatusNoContent, Data: nil,
		Message: "NoContent."})
	return
}