public async Task MsgControllerFilter() { var data = new MsgApiDataHandler(); var list = new List <MsgDisplay> { MsgData.GetFirstDisplay(false) }; var filter = new MsgFilter { TenantRestrict = true }; data.Result.Setup(m => m.Execute(It.IsAny <MsgDisplayByFilter>())).Returns(list); var controller = new MsgController(data, Cloud, Logic) { CurrentUser = StandardUser }; var result = await controller.Filter(filter) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().NotBeNull(); var check = result.Value as PagedResult <IEnumerable <MsgDisplay> >; check.Should().NotBeNull(); check.Data.Count().Should().Be(list.Count); Assert.That(check.Data, Is.DeepEqualTo(list)); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <MsgDisplayByFilter>()), Times.Once()); }
private static MsgFilter MessageFilter(SocketMessage arg) { var ToRet = new MsgFilter { MsgPassed = false }; if (StoreHandler.LoadData(arg.Author.Id, $"GLOBALCHAT-BAN") == null) { if (!(arg.Attachments.Count > 0)) { if (!(arg.Content.ToLower().Contains("http") && arg.Content.ToLower().Contains("discord")) && !(arg.Content.ToLower().Contains("discord") && arg.Content.ToLower().Contains("inv")) && !arg.Content.ToLower().Contains("discord.gg") && !arg.Content.ToLower().Contains(".gg/")) { ToRet.MsgPassed = true; } else { ToRet.Reason = "Discord invites can't be sent through here, let's keep this place as ad-free as possible."; } } else { ToRet.Reason = $"Images/files can't be sent through global chat - *Most* links can though!"; } } else { ToRet.Reason = $"You have been banned from global chat for this reason: - {StoreHandler.LoadData(arg.Author.Id, $"GLOBALCHAT-BAN")}"; } return(ToRet); }
public void Pull(MsgFilter _filter, MsgHandler _handler) { Pulled.Add(new PullHandler { filter = _filter, handler = _handler, }); }
public MainForm() : base() { InitializeComponent(); Dispose += Dispose_Delegate; int scrHeight, scrWidth; Left = 0; Top = 0; FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Normal; scrHeight = Screen.PrimaryScreen.Bounds.Height; //System.Windows.SystemParameters.PrimaryScreenHeight; scrWidth = Screen.PrimaryScreen.Bounds.Width; //System.Windows.SystemParameters.PrimaryScreenWidth; Width = scrWidth; Height = scrHeight; tmr = new System.Timers.Timer(); tmr.Interval = 399; tmr.Enabled = true; tmr.Elapsed += new System.Timers.ElapsedEventHandler(tmr_Elapsed); tmr.Start(); Opacity = 0; ShowInTaskbar = false; MsgFilter.OnMsgProcess += new MsgFilter.MsgProcessDelegate(delegate(ref Message m) { switch (m.Msg) { //WM_QUERYENDSESSION case (0x0011): m.Result = IntPtr.Zero; return(true); //WM_SYSCOMAND SC_SCREENSAVE SC_MONITORPOWER case (0x0112): if (m.LParam == (IntPtr)0xF140 || m.LParam == (IntPtr)0XF170) { m.Result = IntPtr.Zero; return(true); } else { return(false); } default: return(false); } }); MsgFilter.Start(); }
public async Task <IActionResult> Filter([FromBody] MsgFilter viewModel) { if (!viewModel.AuthorKeys.Any() && !viewModel.RecipientKeys.Any()) { viewModel.RecipientKeys.Add(CurrentUser.Id); } var query = new MsgDisplayByFilter { Filter = viewModel, CurrentUser = CurrentUser }; await DataHandler.Execute(query); return(Ok(new PagedResult <IEnumerable <MsgDisplay> > { Data = Secure(query.Result), Paging = query.Paging, Success = true })); }
public async Task MsgDisplayByFilterDataTestPrivate() { var filter = new MsgFilter { PrivateRestrict = true, Take = 10 }; using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var query = new MsgDisplayByFilter { Session = session, Filter = filter, CurrentUser = StandardUser }; await query.Execute(); query.Result.Should().NotBeNull(); query.Result.Count().Should().Be(0); }
public void OrCondTest() { List <Message> messages = InitMessages(); var filterObj = new MsgFilterObj() { Messages = messages, User = "******", MessageText = "H", StartTime = null, EndTime = null, UseAndForCond = false }; IEnumerable <Message> act_msgs = MsgFilter.ApplyFilter(filterObj); bool isSequenceEqual = Enumerable.SequenceEqual(messages, act_msgs); Assert.IsTrue(isSequenceEqual); }
public async Task MsgDisplayByFilterDataTestSearch() { var filter = new MsgFilter { Search = "test", Take = 10 }; using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var query = new MsgDisplayByFilter { Session = session, Filter = filter, CurrentUser = StandardUser }; await query.Execute(); query.Result.Should().NotBeNull(); query.Result.Count().Should().Be(1); Assert.That(query.Result.First(), Is.DeepEqualTo(MsgData.GetFirstDisplay(false))); }
public async Task MsgDisplayByFilterDataTestDate() { var filter = new MsgFilter { DateFrom = DateTime.UtcNow.AddDays(-1), DateTo = DateTime.UtcNow.AddDays(1), Take = 10, Skip = 1 }; using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var query = new MsgDisplayByFilter { Session = session, Filter = filter, CurrentUser = StandardUser }; await query.Execute(); query.Result.Should().NotBeNull(); query.Result.Count().Should().Be(0); filter.Skip.Should().Be(1); filter.Start.Should().Be(10); query.Favourites.Should().Be(0); }
public void AndCondTest() { List <Message> messages = InitMessages(); var filterObj = new MsgFilterObj() { Messages = messages, User = "******", MessageText = "H", StartTime = now, EndTime = now, UseAndForCond = true }; IEnumerable <Message> exp_msgs = new List <Message> { messages[0], messages[1] }; IEnumerable <Message> act_msgs = MsgFilter.ApplyFilter(filterObj); bool isSequenceEqual = Enumerable.SequenceEqual(exp_msgs, act_msgs); Assert.IsTrue(isSequenceEqual); }
private void RefreshMessagesView() { var filterObj = new MsgFilterObj() { Messages = Mobile.MessageStorage.GetMessages().ToList(), User = UsersComboBox.SelectedItem as string, MessageText = MsgSearchTextBox.Text, StartTime = null, EndTime = null, UseAndForCond = UseAndCheckBox.Checked }; if (MsgStartDateTime.Checked) { filterObj.StartTime = MsgStartDateTime.Value; } if (MsgEndDateTime.Checked) { filterObj.EndTime = MsgEndDateTime.Value; } ShowMessages(MsgFilter.ApplyFilter(filterObj)); }