demote/promote vip
This commit is contained in:
parent
38e7060d86
commit
a6628a62a4
1 changed files with 183 additions and 29 deletions
|
@ -101,9 +101,14 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Usage :
|
Usage :
|
||||||
|
|
||||||
promote <user>
|
promote <user>
|
||||||
|
promote -m <user>
|
||||||
|
promote -mod <user>
|
||||||
|
|
||||||
demote <user>
|
demote <user>
|
||||||
|
|
||||||
|
promote -v <user>
|
||||||
|
promote -vip <user>
|
||||||
|
|
||||||
promote -admin <user>
|
promote -admin <user>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -149,7 +154,15 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
// [x] 1. Get trgusr (regardless of -admin flag)
|
// [x] 1. Get trgusr (regardless of -admin flag)
|
||||||
|
|
||||||
let targetusr = if arg1 == Some("-admin") { arg2 } else { arg1 };
|
// let targetusr = if arg1 == Some("-admin") { arg2 } else { arg1 };
|
||||||
|
let targetusr = if
|
||||||
|
arg1 == Some("-admin")
|
||||||
|
|| arg1 == Some("-v")
|
||||||
|
|| arg1 == Some("-vip")
|
||||||
|
|| arg1 == Some("-m")
|
||||||
|
|| arg1 == Some("-mod")
|
||||||
|
{ arg2 }
|
||||||
|
else { arg1 };
|
||||||
|
|
||||||
// [x] 2. promote trguser
|
// [x] 2. promote trguser
|
||||||
|
|
||||||
|
@ -166,21 +179,43 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Some("identity.rs > cmd_promote()".to_string()),
|
Some("identity.rs > cmd_promote()".to_string()),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
Log::flush();
|
Log::flush();
|
||||||
|
|
||||||
let target_bot_admin_role = if arg1 == Some("-admin") {
|
|
||||||
|
// // Believe this is just using this as a Constaint depending on input
|
||||||
|
// let target_bot_admin_role =
|
||||||
|
// if arg1 == Some("-admin") {
|
||||||
|
// Some(UserRole::BotAdmin)
|
||||||
|
// } else {
|
||||||
|
// None
|
||||||
|
// };
|
||||||
|
|
||||||
|
let target_role =
|
||||||
|
if arg1 == Some("-admin") {
|
||||||
Some(UserRole::BotAdmin)
|
Some(UserRole::BotAdmin)
|
||||||
|
} else if arg1 == Some("-vip") || arg1 == Some("-v") {
|
||||||
|
Some(UserRole::VIP(Channel(targetchnl.clone())))
|
||||||
} else {
|
} else {
|
||||||
None
|
None // [x] Internal promote() logic automatically considers trg_role targetting -mod or -m
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// let target_bot_admin_role =
|
||||||
|
// if arg1 == Some("-admin") {
|
||||||
|
// Some(UserRole::BotAdmin)
|
||||||
|
// } else if arg1 == Some("-v") {
|
||||||
|
// Some(UserRole::VIP)
|
||||||
|
// } else {
|
||||||
|
// None
|
||||||
|
// };
|
||||||
|
|
||||||
idlock
|
idlock
|
||||||
.promote(
|
.promote(
|
||||||
sendername.clone(),
|
sendername.clone(),
|
||||||
&sender_badge,
|
&sender_badge,
|
||||||
targetusr.to_string(),
|
targetusr.to_string(),
|
||||||
Some(Channel(targetchnl.clone())),
|
Some(Channel(targetchnl.clone())),
|
||||||
target_bot_admin_role,
|
target_role,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -279,13 +314,21 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
demote <user>
|
demote <user>
|
||||||
|
|
||||||
promote -admin <user>
|
demote -m <user>
|
||||||
|
demote -mod <user>
|
||||||
|
|
||||||
|
demote -v <user>
|
||||||
|
demote -vip <user>
|
||||||
|
|
||||||
|
// promote -admin <user>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// [x] Unwraps arguments from message
|
// [x] Unwraps arguments from message
|
||||||
|
|
||||||
let (arg1, _arg2) = {
|
let (arg1, arg2) = {
|
||||||
let mut argv = params.msg.message_text.split(' ');
|
let mut argv = params.msg.message_text.split(' ');
|
||||||
|
|
||||||
argv.next(); // Skip the command name
|
argv.next(); // Skip the command name
|
||||||
|
@ -341,10 +384,29 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
let sender_badge = sender_badge_mut;
|
let sender_badge = sender_badge_mut;
|
||||||
|
|
||||||
let targetusr = arg1;
|
|
||||||
|
|
||||||
let targetchnl = params.msg.channel_login.to_lowercase();
|
let targetchnl = params.msg.channel_login.to_lowercase();
|
||||||
|
|
||||||
|
|
||||||
|
// let targetusr = arg1;
|
||||||
|
let targetusr = if
|
||||||
|
arg1 == Some("-v")
|
||||||
|
|| arg1 == Some("-vip")
|
||||||
|
|| arg1 == Some("-m")
|
||||||
|
|| arg1 == Some("-mod")
|
||||||
|
{ arg2 }
|
||||||
|
else { arg1 };
|
||||||
|
|
||||||
|
// Note : At the moment, no handling of -admin
|
||||||
|
let target_role =
|
||||||
|
if arg1 == Some("-vip") || arg1 == Some("-v") {
|
||||||
|
Some(UserRole::VIP(Channel(targetchnl.clone())))
|
||||||
|
} else {
|
||||||
|
None // [x] Internal promote() logic automatically considers trg_role targetting -mod or -m
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
- [x] 2. Run Demote()
|
- [x] 2. Run Demote()
|
||||||
|
@ -376,6 +438,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
&sender_badge,
|
&sender_badge,
|
||||||
targetusr.to_string(),
|
targetusr.to_string(),
|
||||||
Some(Channel(targetchnl.clone())),
|
Some(Channel(targetchnl.clone())),
|
||||||
|
target_role,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -800,13 +863,15 @@ impl IdentityManager {
|
||||||
let mut rolechange = ChangeResult::NoChange("".to_string());
|
let mut rolechange = ChangeResult::NoChange("".to_string());
|
||||||
|
|
||||||
match chat_badge {
|
match chat_badge {
|
||||||
// [x] If chatBadge::Broadcaster ...
|
|
||||||
// [x] and cmdreqroles includes UserRole::Broadcaster , Ok(Permissible::Allow)
|
// If ChatBadge::Broadcaster is observed,
|
||||||
// [x] and cmdreqroles includes UserRole::Mod("") OR UserRole::SupMod("") , Ok(Permissible::Allow)
|
// Check if cmdreqroles contains Channel Level Roles . Broadcaster should have Permissible::Allow for any of these
|
||||||
|
|
||||||
Some(ChatBadge::Broadcaster) => {
|
Some(ChatBadge::Broadcaster) => {
|
||||||
if cmdreqroles.contains(&UserRole::Broadcaster)
|
if cmdreqroles.contains(&UserRole::Broadcaster)
|
||||||
|| cmdreqroles.contains(&UserRole::Mod(OF_CMD_CHANNEL))
|
|| cmdreqroles.contains(&UserRole::Mod(OF_CMD_CHANNEL))
|
||||||
|| cmdreqroles.contains(&UserRole::SupMod(OF_CMD_CHANNEL))
|
|| cmdreqroles.contains(&UserRole::SupMod(OF_CMD_CHANNEL))
|
||||||
|
|| cmdreqroles.contains(&UserRole::VIP(OF_CMD_CHANNEL))
|
||||||
{
|
{
|
||||||
// return Ok(Permissible::Allow)
|
// return Ok(Permissible::Allow)
|
||||||
return (
|
return (
|
||||||
|
@ -1075,20 +1140,27 @@ impl IdentityManager {
|
||||||
Log::flush();
|
Log::flush();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
// [x] => 03.25 - Q. Would there need to be extra handling here for VIP?
|
||||||
|
|
||||||
|
|
||||||
[x] 1. Check if Authorizer Mod Badge then Auto Promote to Mod if not Mod
|
[x] 1. Check if Authorizer Mod Badge then Auto Promote to Mod if not Mod
|
||||||
[x] 2. Get Authorizer & Target Chatter Roles with a Given Channel
|
[x] 2. Get Authorizer & Target Chatter Roles with a Given Channel
|
||||||
[x] 3. If the authorizer & Target Chatters are the same, and the Authorizer is not a Admin, return no change
|
[x] 3. If the authorizer & Target Chatters are the same, and the Authorizer is not a Admin, return no change
|
||||||
[x] 4a. If Authorizer is BotAdmin & trg_role is Some(BotAdmin) , set Target as BotAdmin and return
|
[x] 4a. If Authorizer is BotAdmin & trg_role is Some(BotAdmin) , set Target as BotAdmin and return
|
||||||
[x] 4b. If target is Broadcaster, return NoChange
|
[x] 4b. If Authorizer is a Mod,SupMod,Broadcaster & trg_role is Some(VIP(channel)), can Promote a Target Chatter > VIP
|
||||||
[ ] 4c. If Authorizer is a SupMod,Broadcaster,BotAdmin , can Promote Target Chatter > Mod
|
[x] 4c. If target is Broadcaster, return NoChange
|
||||||
|
[x] 4d. If Authorizer is a SupMod,Broadcaster,BotAdmin , can Promote Target Chatter > Mod
|
||||||
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
||||||
[ ] 4d. If Authorizer is a Broadcaster,BotAdmin , can Promote a Target Mod > SupMod
|
[x] 4e. If Authorizer is a Broadcaster,BotAdmin , can Promote a Target Mod > SupMod
|
||||||
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// [x] 1. Check if Authorizer Mod Badge then Auto Promote to Mod if not Mod
|
// [x] 1. Check if Authorizer Mod or VIP Badge then Auto Promote to matching UserRole if not already assigned
|
||||||
|
|
||||||
let trgchatter = trgchatter.to_lowercase();
|
let trgchatter = trgchatter.to_lowercase();
|
||||||
|
|
||||||
|
@ -1110,10 +1182,23 @@ impl IdentityManager {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// [x] - May want to Auto VIP Authorizer here
|
||||||
|
Some(ChatBadge::VIP)
|
||||||
|
if (!authusrroles.contains(&UserRole::VIP(channel.clone()))) =>
|
||||||
|
{
|
||||||
|
authusrroles.push(UserRole::VIP(channel.clone()));
|
||||||
|
|
||||||
|
self.affirm_chatter_in_db(authorizer.clone()).await;
|
||||||
|
self.add_role(authorizer.clone(), UserRole::VIP(channel.clone()))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// [x] 2. Get Authorizer & Target Chatter Roles
|
// [x] 2. Get Authorizer & Target Chatter Roles
|
||||||
|
|
||||||
let trgusrroles = self
|
let trgusrroles = self
|
||||||
|
@ -1131,7 +1216,6 @@ impl IdentityManager {
|
||||||
|
|
||||||
(authusrroles, trgusrroles)
|
(authusrroles, trgusrroles)
|
||||||
};
|
};
|
||||||
|
|
||||||
// [x] 3. If the authorizer & Target Chatters are the same, and the Authorizer is not a Admin, return no change
|
// [x] 3. If the authorizer & Target Chatters are the same, and the Authorizer is not a Admin, return no change
|
||||||
if trgchatter == authorizer && !authusrroles.contains(&UserRole::BotAdmin) {
|
if trgchatter == authorizer && !authusrroles.contains(&UserRole::BotAdmin) {
|
||||||
return ChangeResult::NoChange("Can't target yourself".to_string());
|
return ChangeResult::NoChange("Can't target yourself".to_string());
|
||||||
|
@ -1150,20 +1234,47 @@ impl IdentityManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// [x] 4b. If target is Broadcaster, return NoChange
|
// [x] 4b. If Authorizer is a Mod,SupMod,Broadcaster & trg_role is Some(VIP(channel)), can Promote a Target Chatter > VIP
|
||||||
|
if let Some(trg_chnl) = channel.clone() {
|
||||||
|
if ( authusrroles.contains(&UserRole::Mod(trg_chnl.clone()))
|
||||||
|
|| authusrroles.contains(&UserRole::SupMod(trg_chnl.clone()))
|
||||||
|
|| authusrroles.contains(&UserRole::Broadcaster)
|
||||||
|
)
|
||||||
|
&& trg_role == Some(UserRole::VIP(trg_chnl.clone())) {
|
||||||
|
if trgusrroles.contains(&UserRole::VIP(trg_chnl.clone())) {
|
||||||
|
return ChangeResult::NoChange("Already has the role".to_string());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.affirm_chatter_in_db(trgchatter.clone()).await;
|
||||||
|
|
||||||
|
self.add_role(trgchatter.clone(), UserRole::VIP(trg_chnl.clone())).await;
|
||||||
|
|
||||||
|
return ChangeResult::Success("Promotion Successful".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// [x] 4c. If target is Broadcaster, return NoChange
|
||||||
|
|
||||||
if trgusrroles.contains(&UserRole::Broadcaster) {
|
if trgusrroles.contains(&UserRole::Broadcaster) {
|
||||||
return ChangeResult::NoChange("Can't target broadcaster".to_string());
|
return ChangeResult::NoChange("Can't target broadcaster".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
[ ] 4c. If Authorizer is a SupMod,Broadcaster,BotAdmin , can Promote Target Chatter > Mod
|
[x] 4d. If Authorizer is a SupMod,Broadcaster,BotAdmin , can Promote Target Chatter > Mod
|
||||||
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
||||||
[ ] 4d. If Authorizer is a Broadcaster,BotAdmin , can Promote a Target Mod > SupMod
|
[x] 4e. If Authorizer is a Broadcaster,BotAdmin , can Promote a Target Mod > SupMod
|
||||||
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
- NOTE : We do not validate trg_role here - app logic requires you to promote 1 to Mod and 1 more to SupMod
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if let Some(trg_chnl) = channel.clone() {
|
if let Some(trg_chnl) = channel.clone() {
|
||||||
|
|
||||||
|
// 1. Checks first if Target User's Roles do not Include Broadcaster,Mod,SupMod for the Channel
|
||||||
if !trgusrroles.contains(&UserRole::Broadcaster)
|
if !trgusrroles.contains(&UserRole::Broadcaster)
|
||||||
&& !trgusrroles.contains(&UserRole::Mod(trg_chnl.clone()))
|
&& !trgusrroles.contains(&UserRole::Mod(trg_chnl.clone()))
|
||||||
&& !trgusrroles.contains(&UserRole::SupMod(trg_chnl.clone()))
|
&& !trgusrroles.contains(&UserRole::SupMod(trg_chnl.clone()))
|
||||||
|
@ -1172,6 +1283,8 @@ impl IdentityManager {
|
||||||
// target's Next Role would be Mod
|
// target's Next Role would be Mod
|
||||||
// Authorizer must be SupMod,Broadcaster,BotAdmin
|
// Authorizer must be SupMod,Broadcaster,BotAdmin
|
||||||
// > Promote target to Mod
|
// > Promote target to Mod
|
||||||
|
|
||||||
|
// 2. If Authorizer has Elevated Admin Roles for the Channel (SupMod,Broadcaster,BotAdmin) > set target to MOD
|
||||||
if authusrroles.contains(&UserRole::SupMod(trg_chnl.clone()))
|
if authusrroles.contains(&UserRole::SupMod(trg_chnl.clone()))
|
||||||
|| authusrroles.contains(&UserRole::Broadcaster)
|
|| authusrroles.contains(&UserRole::Broadcaster)
|
||||||
|| authusrroles.contains(&UserRole::BotAdmin)
|
|| authusrroles.contains(&UserRole::BotAdmin)
|
||||||
|
@ -1233,6 +1346,8 @@ impl IdentityManager {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
botlog::warn(
|
botlog::warn(
|
||||||
"Runtime reached undeveloped code",
|
"Runtime reached undeveloped code",
|
||||||
Some("identity.rs > promote()".to_string()),
|
Some("identity.rs > promote()".to_string()),
|
||||||
|
@ -1247,6 +1362,7 @@ impl IdentityManager {
|
||||||
authorizer_badge: &Option<ChatBadge>,
|
authorizer_badge: &Option<ChatBadge>,
|
||||||
trgchatter: String,
|
trgchatter: String,
|
||||||
channel: Option<Channel>,
|
channel: Option<Channel>,
|
||||||
|
trg_role: Option<UserRole>,
|
||||||
) -> ChangeResult {
|
) -> ChangeResult {
|
||||||
botlog::trace(&format!("IN VARS for demote() : Authorizer : {:?} ; Target Chatter : {} ; Target Channel : {:?}",
|
botlog::trace(&format!("IN VARS for demote() : Authorizer : {:?} ; Target Chatter : {} ; Target Channel : {:?}",
|
||||||
authorizer,trgchatter,channel), Some("identity.rs > demote()".to_string()), None);
|
authorizer,trgchatter,channel), Some("identity.rs > demote()".to_string()), None);
|
||||||
|
@ -1260,7 +1376,7 @@ impl IdentityManager {
|
||||||
Use the roles of the above to determine whether the authorizer can demote the target user or not
|
Use the roles of the above to determine whether the authorizer can demote the target user or not
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// [x] 1. If Authorizer's Badge is Mod, ensuring Sender is in DB as Mod(Channel)
|
// [x] 1. If Authorizer's Badge is Mod/VIP, ensuring Sender is in DB as Mod(Channel)
|
||||||
|
|
||||||
let trgchatter = trgchatter.to_lowercase();
|
let trgchatter = trgchatter.to_lowercase();
|
||||||
|
|
||||||
|
@ -1283,6 +1399,17 @@ impl IdentityManager {
|
||||||
self.add_role(authorizer.clone(), UserRole::Mod(channel.clone()))
|
self.add_role(authorizer.clone(), UserRole::Mod(channel.clone()))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
// [x] - May want to Auto VIP Authorizer here
|
||||||
|
Some(ChatBadge::VIP)
|
||||||
|
if (!authusrroles.contains(&UserRole::VIP(channel.clone()))) =>
|
||||||
|
{
|
||||||
|
authusrroles.push(UserRole::VIP(channel.clone()));
|
||||||
|
|
||||||
|
self.affirm_chatter_in_db(authorizer.clone()).await;
|
||||||
|
self.add_role(authorizer.clone(), UserRole::VIP(channel.clone()))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1298,7 +1425,30 @@ impl IdentityManager {
|
||||||
return ChangeResult::NoChange("Can't target yourself".to_string());
|
return ChangeResult::NoChange("Can't target yourself".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// [x] 4a. Authorizers who are BotAdmin, Broadcaster or Supermod can demote a Mod
|
// [x] 4. If Authorizer is a Mod,SupMod,Broadcaster & trg_role is Some(VIP(channel)), can Promote a Target Chatter > VIP
|
||||||
|
|
||||||
|
if ( authusrroles.contains(&UserRole::Mod(channel.clone()))
|
||||||
|
|| authusrroles.contains(&UserRole::SupMod(channel.clone()))
|
||||||
|
|| authusrroles.contains(&UserRole::Broadcaster)
|
||||||
|
)
|
||||||
|
&& trg_role == Some(UserRole::VIP(channel.clone())) {
|
||||||
|
if trgusrroles.contains(&UserRole::VIP(channel.clone())) {
|
||||||
|
return ChangeResult::NoChange("Already has the role".to_string());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.affirm_chatter_in_db(trgchatter.clone()).await;
|
||||||
|
|
||||||
|
self.add_role(trgchatter.clone(), UserRole::VIP(channel.clone())).await;
|
||||||
|
|
||||||
|
return ChangeResult::Success("Promotion Successful".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// [x] 5. - Mod/SupMod Logic
|
||||||
|
|
||||||
|
|
||||||
|
// [x] 5a. Authorizers who are BotAdmin, Broadcaster or Supermod can demote a Mod
|
||||||
|
|
||||||
if (authusrroles.contains(&UserRole::BotAdmin)
|
if (authusrroles.contains(&UserRole::BotAdmin)
|
||||||
|| authusrroles.contains(&UserRole::Broadcaster)
|
|| authusrroles.contains(&UserRole::Broadcaster)
|
||||||
|
@ -1309,7 +1459,7 @@ impl IdentityManager {
|
||||||
.await;
|
.await;
|
||||||
return ChangeResult::Success("Demoted successfully".to_string());
|
return ChangeResult::Success("Demoted successfully".to_string());
|
||||||
}
|
}
|
||||||
// [x] 4b. Authorizers who are BotAdmin, Broadcaster can demote a SupMod
|
// [x] 5b. Authorizers who are BotAdmin, Broadcaster can demote a SupMod
|
||||||
else if (authusrroles.contains(&UserRole::BotAdmin)
|
else if (authusrroles.contains(&UserRole::BotAdmin)
|
||||||
|| authusrroles.contains(&UserRole::Broadcaster))
|
|| authusrroles.contains(&UserRole::Broadcaster))
|
||||||
&& trgusrroles.contains(&UserRole::SupMod(channel.clone()))
|
&& trgusrroles.contains(&UserRole::SupMod(channel.clone()))
|
||||||
|
@ -1320,7 +1470,7 @@ impl IdentityManager {
|
||||||
.await;
|
.await;
|
||||||
return ChangeResult::Success("Demoted successfully".to_string());
|
return ChangeResult::Success("Demoted successfully".to_string());
|
||||||
}
|
}
|
||||||
// [x] 4c. When Target chatter isnt a Mod or SupMod to demote
|
// [x] 5c. When Target chatter isnt a Mod or SupMod to demote
|
||||||
else if !trgusrroles.contains(&UserRole::Mod(channel.clone()))
|
else if !trgusrroles.contains(&UserRole::Mod(channel.clone()))
|
||||||
&& !trgusrroles.contains(&UserRole::SupMod(channel.clone()))
|
&& !trgusrroles.contains(&UserRole::SupMod(channel.clone()))
|
||||||
{
|
{
|
||||||
|
@ -1328,7 +1478,7 @@ impl IdentityManager {
|
||||||
"Target chatter does not have a role that can be demoted".to_string(),
|
"Target chatter does not have a role that can be demoted".to_string(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// [x] 4d. When they're only a Mod
|
// [x] 5d. When they're only a Mod
|
||||||
else if authusrroles.contains(&UserRole::Mod(channel.clone())) {
|
else if authusrroles.contains(&UserRole::Mod(channel.clone())) {
|
||||||
return ChangeResult::Failed("You're not permitted to do that".to_string());
|
return ChangeResult::Failed("You're not permitted to do that".to_string());
|
||||||
}
|
}
|
||||||
|
@ -1833,6 +1983,7 @@ mod core_identity {
|
||||||
let authorizer = regmod.clone();
|
let authorizer = regmod.clone();
|
||||||
let authorizer_badge = &None;
|
let authorizer_badge = &None;
|
||||||
let trgchatter = supmod.clone();
|
let trgchatter = supmod.clone();
|
||||||
|
let trg_role = None;
|
||||||
|
|
||||||
let rslt = test_id_mgr
|
let rslt = test_id_mgr
|
||||||
.demote(
|
.demote(
|
||||||
|
@ -1840,6 +1991,7 @@ mod core_identity {
|
||||||
authorizer_badge,
|
authorizer_badge,
|
||||||
trgchatter.clone(),
|
trgchatter.clone(),
|
||||||
channel.clone(),
|
channel.clone(),
|
||||||
|
trg_role.clone(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -1860,6 +2012,7 @@ mod core_identity {
|
||||||
authorizer_badge,
|
authorizer_badge,
|
||||||
trgchatter.clone(),
|
trgchatter.clone(),
|
||||||
channel.clone(),
|
channel.clone(),
|
||||||
|
trg_role.clone(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -1874,6 +2027,7 @@ mod core_identity {
|
||||||
authorizer_badge,
|
authorizer_badge,
|
||||||
trgchatter.clone(),
|
trgchatter.clone(),
|
||||||
channel.clone(),
|
channel.clone(),
|
||||||
|
trg_role.clone(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue