public IActionResult Publish([FromBody] PublishInput input) { Logger.LogDebug($"PublishMessageController - Publish method called with this input: {input}"); if (input == null) { return(BadRequest(new ApiValidationError(nameof(input), ErrorKeys.ParameterNull))); } if (input.Payload == null) { return(BadRequest(new ApiValidationError(nameof(PublishInput.Payload), ErrorKeys.ParameterNull))); } if (string.IsNullOrWhiteSpace(input.Category)) { return(BadRequest(new ApiValidationError(nameof(PublishInput.Category), ErrorKeys.ParameterNull))); } if (!input.ValidateTags()) { return(BadRequest(new ApiValidationError(nameof(PublishInput.Tags), ErrorKeys.ParameterNull))); } var result = _publishMessageLogic.ProduceMessage(input); if (!string.IsNullOrEmpty(result.Error)) { return(BadRequest(new { Message = result.Error })); } return(Ok(ApiValidationResult.Ok())); }
// Start is called before the first frame update void Start() { text_ui = GetComponent <TextMeshProUGUI>(); emitter = GetComponent <PublishInput>(); if (cursor_blink_time > 0) { InvokeRepeating("BlinkCursor", 0.1f, cursor_blink_time); } }
protected override void beforeEach() { theSpec = new NugetSpec("Nug", "Nug.nuspec"); theInput = new PublishInput { Version = "1.0.0", ArtifactsFlag = "arts", ApiKey = "pw" }; }
public void Given_Sane_Tags_ValidateTags_Should_Return_True() { var input = new PublishInput { Tenant = "sample-tenant", Category = "sample-category", Payload = "sample-payload", Tags = new[] { "t1", " ", "t2" } }; Assert.True(input.ValidateTags()); }
public void Given_List_With_Empty_Strings_As_Tags_ValidateTags_Should_Return_False() { var input = new PublishInput { Tenant = "sample-tenant", Category = "sample-category", Payload = "sample-payload", Tags = new[] { "", " ", "\t" } }; Assert.False(input.ValidateTags()); }
public void Given_Empty_List_ValidateTags_Should_Return_False() { var input = new PublishInput { Tenant = "sample-tenant", Category = "sample-category", Payload = "sample-payload", Tags = new List <string>() }; Assert.False(input.ValidateTags()); }
public ProduceMessageOutput ProduceMessage(PublishInput input) { try { _producer.Produce(input.Tenant, input); return(new ProduceMessageOutput { Success = true }); } catch (Exception ex) { Logger.LogError($"PublishMessageLogic - ProduceMessage: {ex.Message}", ex); return(new ProduceMessageOutput { Success = false, Error = ErrorKeys.UnableProduceMessage }); } }
public override Hash Publish(PublishInput input) { // TODO: Maybe need to check permission. var novelId = Context.GenerateId(Context.Self, HashHelper.ConcatAndCompute(HashHelper.ComputeFrom(Context.Sender), HashHelper.ComputeFrom(input.NovelTextHash))); Assert(State.NovelInfos[novelId] == null, "Novel already exists."); var setInfo = State.NovelSetInfos[input.SetId]; if (setInfo == null) { throw new AssertionException($"Set with Id {input.SetId} not found."); } var rank = setInfo.NovelCount.Add(1); setInfo.NovelCount = rank; State.NovelHashes[input.SetId][rank] = novelId; State.NovelSetInfos[input.SetId] = setInfo; State.NovelInfos[novelId] = new NovelInfo { SetId = input.SetId, Length = input.Length, NovelId = novelId, NovelName = input.NovelName, NovelTextHash = input.NovelTextHash, PublisherAddress = Context.Sender, PublishTime = Context.CurrentBlockTime, LatestEditTime = Context.CurrentBlockTime, Text = input.Text }; var profile = State.Profiles[Context.Sender]; if (profile == null) { profile = new Profile { Address = Context.Sender, FirstPublishTime = Context.CurrentBlockTime, }; } else { if (profile.FirstPublishTime == null) { profile.FirstPublishTime = Context.CurrentBlockTime; } } State.Profiles[Context.Sender] = profile; Context.Fire(new NovelPublished { SetId = input.SetId, Length = input.Length, NovelId = novelId, NovelName = input.NovelName, NovelTextHash = input.NovelTextHash, PublisherAddress = Context.Sender, PublishTime = Context.CurrentBlockTime, }); return(novelId); }
void Start() { emitter = GetComponent <PublishInput>(); StartDictationEngine(); }