Skip to content

Commit 7f16eae

Browse files
authored
Merge pull request #769 from Qtoss-AI/master
Redis Event
2 parents be687bd + 5a3478d commit 7f16eae

File tree

25 files changed

+450
-75
lines changed

25 files changed

+450
-75
lines changed

src/Infrastructure/BotSharp.Abstraction/Browsing/Enums/BroswerActionEnum.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public enum BroswerActionEnum
77
Typing = 3,
88
Hover = 4,
99
Scroll = 5,
10+
DragAndDrop = 6
1011
}

src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementPosition.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ public class ElementPosition
55
public float X { get; set; } = default!;
66

77
public float Y { get; set; } = default!;
8+
9+
public override string ToString()
10+
{
11+
return $"[{X}, {Y}]";
12+
}
813
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace BotSharp.Abstraction.Infrastructures.Enums;
2+
3+
public enum EventPriority
4+
{
5+
Low = 1,
6+
Medium = 2,
7+
High = 3
8+
}

src/Infrastructure/BotSharp.Abstraction/Infrastructures/Events/IEventPublisher.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ public interface IEventPublisher
1010
/// <returns></returns>
1111
Task BroadcastAsync(string channel, string message);
1212

13-
Task PublishAsync(string channel, string message);
13+
Task<string?> PublishAsync(string channel, string message, EventPriority? priority = null);
1414

1515
Task ReDispatchAsync(string channel, int count = 10, string order = "asc");
16+
17+
Task ReDispatchPendingAsync(string channel, string group, int count = 10);
18+
19+
Task RemoveAsync(string channel, int count = 10);
1620
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
using System.Threading;
2+
13
namespace BotSharp.Abstraction.Infrastructures.Events;
24

35
public interface IEventSubscriber
46
{
57
Task SubscribeAsync(string channel, Func<string, string, Task> received);
68

7-
Task SubscribeAsync(string channel, string group, Func<string, string, Task> received);
9+
Task SubscribeAsync(string channel, string group, int? port, bool priorityEnabled,
10+
Func<string, string, Task> received,
11+
CancellationToken? stoppingToken = null);
812
}

src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public override void OnSuccess(MethodContext context)
5050
}
5151

5252
var httpContext = Services.GetRequiredService<IHttpContextAccessor>();
53-
if (httpContext.HttpContext.Response.Headers["Cache-Control"].ToString().Contains("no-store"))
53+
if (httpContext != null &&
54+
httpContext.HttpContext != null &&
55+
httpContext.HttpContext.Response.Headers["Cache-Control"].ToString().Contains("no-store"))
5456
{
5557
return;
5658
}

src/Infrastructure/BotSharp.Abstraction/Repositories/BotSharpDatabaseSettings.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ namespace BotSharp.Abstraction.Repositories;
22

33
public class BotSharpDatabaseSettings : DatabaseBasicSettings
44
{
5-
public string[] Assemblies { get; set; }
6-
public string FileRepository { get; set; }
7-
public string BotSharpMongoDb { get; set; }
8-
public string TablePrefix { get; set; }
9-
public DbConnectionSetting BotSharp { get; set; }
10-
public string Redis { get; set; }
5+
public string[] Assemblies { get; set; } = [];
6+
public string FileRepository { get; set; } = string.Empty;
7+
public string BotSharpMongoDb { get; set; } = string.Empty;
8+
public string TablePrefix { get; set; } = string.Empty;
9+
public DbConnectionSetting BotSharp { get; set; } = new();
10+
public string Redis { get; set; } = string.Empty;
11+
public bool EnableReplica { get; set; } = true;
1112
}
1213

1314
public class DatabaseBasicSettings
1415
{
15-
public string Default { get; set; }
16-
public DbConnectionSetting DefaultConnection { get; set; }
16+
public string Default { get; set; } = string.Empty;
17+
public DbConnectionSetting DefaultConnection { get; set; } = new();
1718
public bool EnableSqlLog { get; set; }
1819
public bool EnableSensitiveDataLogging { get; set; }
1920
public bool EnableRetryOnFailure { get; set; }
@@ -23,9 +24,11 @@ public class DbConnectionSetting
2324
{
2425
public string Master { get; set; }
2526
public string[] Slavers { get; set; }
27+
public int ConnectionTimeout { get; set; } = 30;
28+
public int ExecutionTimeout { get; set; } = 30;
2629

2730
public DbConnectionSetting()
2831
{
29-
Slavers = new string[0];
32+
Slavers = [];
3033
}
3134
}

src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using BotSharp.Abstraction.Shared;
66
using BotSharp.Abstraction.Tasks.Models;
77
using BotSharp.Abstraction.Translation.Models;
8+
using BotSharp.Abstraction.Users.Enums;
89
using BotSharp.Abstraction.Users.Models;
910
using BotSharp.Abstraction.VectorStorage.Models;
1011

@@ -26,7 +27,7 @@ public interface IBotSharpRepository : IHaveServiceProvider
2627

2728
#region User
2829
User? GetUserByEmail(string email) => throw new NotImplementedException();
29-
User? GetUserByPhone(string phone, string role = null, string regionCode = "CN") => throw new NotImplementedException();
30+
User? GetUserByPhone(string phone, string type = UserType.Client, string regionCode = "CN") => throw new NotImplementedException();
3031
User? GetAffiliateUserByPhone(string phone) => throw new NotImplementedException();
3132
User? GetUserById(string id) => throw new NotImplementedException();
3233
List<User> GetUserByIds(List<string> ids) => throw new NotImplementedException();

src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class User
2323
public bool Verified { get; set; }
2424
public string RegionCode { get; set; } = "CN";
2525
public string? AffiliateId { get; set; }
26+
public string? ReferralCode { get; set; }
2627
public string? EmployeeId { get; set; }
2728
public bool IsDisabled { get; set; }
2829
public IEnumerable<string> Permissions { get; set; } = [];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace BotSharp.Abstraction.Utilities;
2+
3+
public static class MathExt
4+
{
5+
public static int Max(int a, int b, int c)
6+
{
7+
return Math.Max(Math.Max(a, b), c);
8+
}
9+
10+
public static long Max(long a, long b, long c)
11+
{
12+
return Math.Max(Math.Max(a, b), c);
13+
}
14+
}

0 commit comments

Comments
 (0)