Ejemplo n.º 1
0
func _respond(call otto.FunctionCall) otto.Value {
	response, _ := call.Argument(0).ToString()
	client := client.Client{
		Host:          viper.GetString("host"),
		AccessKey:     viper.GetString("access_key"),
		AccessKeyName: viper.GetString("access_key_name"),
		ShowRequests:  viper.GetBool("show_requests"),
	}
	if client.AccessKeyName == "" {
		client.AccessKeyName = viper.GetString("mailbox")
	}
	messageId := getConstant(call.Otto, "SCRIPT_ID")
	err := client.Respond(messageId, response, false)
	if err != nil {
		jsThrow(call, err)
	}
	var v otto.Value
	v, _ = otto.ToValue(true)
	return v
}