Clan Requests#856
Conversation
…ts. Notify users on login when clan request approved.
| "clan_id", "requester_character_id", "created", "approved" | ||
| }; | ||
|
|
||
| private readonly string SqlInsertClanRequest = $""" |
There was a problem hiding this comment.
Today I learned that C# will let you combine interpolated strings and raw strings.
| public class ClanRequestMigration : IMigrationStrategy | ||
| { | ||
| public uint From => 43; | ||
| public uint To => 44; |
There was a problem hiding this comment.
This may get bumped to 45 depending on the cadence of #822
| public bool CheckPermission(uint characterId, ClanPermission perm) | ||
| { | ||
| var (clanId, member) = ClanMembership(characterId); | ||
| var splitPerms = IntToEnums<ClanPermission>((int)member.Permission); |
There was a problem hiding this comment.
I know I wrote this stupid IntToEnums thing but apparently it's supposed to be a [Flags] Enum and then it just works without all this extra machinery.
|
|
||
| if (shouldDelete) | ||
| { | ||
| Server.Database.ExecuteInTransaction(conn => |
There was a problem hiding this comment.
There's likely a way we can rearrange this logic such that a second transaction is not required.
There was a problem hiding this comment.
Marking things as done in a commit-to-be. Has been reworked into a single transaction with network comms outside.
|
|
||
| namespace Arrowgene.Ddon.Shared.Entity.PacketStructure | ||
| { | ||
| public class C2SClanClanJoinRequest : IPacketStructure |
There was a problem hiding this comment.
C2SClanClanRegisterJoinReq
There was a problem hiding this comment.
Marking things as done in a commit-to-be. Renamed.
| { | ||
| Server.Database.InsertClanRequest(request.ClanId, client.Character.CharacterId, conn); | ||
| }); | ||
| return new S2CClanClanJoinRes(); |
There was a problem hiding this comment.
This feels like it should be sending a notice to people who are currently online and can handle the application.
|
|
||
| namespace Arrowgene.Ddon.GameServer.Handler | ||
| { | ||
| public class ClanClanJoinRequestHandler : GameRequestPacketHandler<C2SClanClanJoinRequest, S2CClanClanJoinRes> |
There was a problem hiding this comment.
See comments about the misnamed packets, which would render this ClanClanRegisterJoinHandler
There was a problem hiding this comment.
Marking things as done in a commit-to-be. Renamed.
|
|
||
| namespace Arrowgene.Ddon.GameServer.Handler | ||
| { | ||
| public class ClanClanApproveJoinRequestHandler : GameRequestPacketHandler<C2SClanClanApproveJoinReq, S2CClanClanApproveJoinRes> |
There was a problem hiding this comment.
ClanClanApproveJoinHandler
There was a problem hiding this comment.
Marking things as done in a commit-to-be. Renamed.
|
|
||
| namespace Arrowgene.Ddon.GameServer.Handler | ||
| { | ||
| public class ClanClanCancelJoinRequestHandler : GameRequestPacketHandler<C2SClanClanCancelJoinReq, S2CClanClanCancelJoinRes> |
There was a problem hiding this comment.
ClanClanCancelJoinHandler
Also this has a notice associated with it, so you likely need to be notifying other clients that the request has been cancelled.
| UInt32 clanId = Server.Database.GetClanRequestsByCharacter(request.CharacterId, conn).First().ClanId; | ||
| Server.ClanManager.JoinClan(request.CharacterId, clanId, conn); | ||
|
|
||
| if (Server.ClientLookup.GetClientByCharacterId(request.CharacterId) == null) |
There was a problem hiding this comment.
This is made somewhat more complicated by the fact that this player may be online, but on a different channel. You can semi-reliably find them with Server.RpcManager.FindPlayerById(request.CharacterId), but you'll have to send an RPC message to their server (if FindPlayer returns >0) to tell them that they've been accepted. You'll have to add a new command to PacketRoute to accommodate a packet for a single person.
| private const string DefaultSchemaFile = "Script/schema_sqlite.sql"; | ||
|
|
||
| public const uint Version = 43; | ||
| public const uint Version = 44; |
There was a problem hiding this comment.
Same as #822, we have to be careful with the merged
| bool DeleteClanBaseCustomization(uint clanId, byte type, DbConnection? connectionIn = null); | ||
| List<CDataClanSearchResult> SearchClans(CDataClanSearchParam param, DbConnection? connectionIn = null); | ||
| bool InsertClanRequest(uint clanId, uint characterId, DbConnection? connectionIn = null); | ||
| List<CDataClanJoinRequest> GetClanRequestsByCharacter(uint characterId, DbConnection? connectionIn = null); |
There was a problem hiding this comment.
Considering there can only be one application, shouldn't these return a single entity instead of a list?
| public abstract CDataClanMemberInfo GetClanMember(uint characterId, DbConnection? connectionIn = null); | ||
| public abstract bool UpdateClanMember(CDataClanMemberInfo memberInfo, uint clanId, DbConnection? connectionIn = null); | ||
| public abstract bool InsertClanRequest(uint clanId, uint characterId, DbConnection? connectionIn = null); | ||
| public abstract List<CDataClanJoinRequest> GetClanRequestsByCharacter(uint characterId, DbConnection? connectionIn = null); |
| character = Server.CharacterManager.SelectCharacter(characterId, false, connectionIn); | ||
| if (character == null) | ||
| { | ||
| Logger.Error("Tried to add offline character to clan but select character query failed."); |
There was a problem hiding this comment.
This should probably throw a ResponseErrorException with an appropriate error code so the user can see an error happening instead of having the client follow along thinking it succeeded
Continues work on Clan Search by implementing the Clan Request feature. This allows characters to request access to a clan, with approval performed by clan owners or clan members with appropriate permissions set. The scouting system remains unimplemented.
Changes:
Quirks / potential issues:
Checklist:
developbranch