content_directory.rs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. use crate::{AccountId, ContentDirectoryWorkingGroupInstance, MemberId, Runtime};
  2. // Alias for content directory working group
  3. pub(crate) type ContentDirectoryWorkingGroup<T> =
  4. working_group::Module<T, ContentDirectoryWorkingGroupInstance>;
  5. impl content_directory::ActorAuthenticator for Runtime {
  6. type CuratorId = u64;
  7. type MemberId = MemberId;
  8. type CuratorGroupId = u64;
  9. fn is_lead(account_id: &AccountId) -> bool {
  10. // get current lead id
  11. let maybe_current_lead_id = ContentDirectoryWorkingGroup::<Runtime>::current_lead();
  12. if let Some(ref current_lead_id) = maybe_current_lead_id {
  13. if let Ok(worker) =
  14. ContentDirectoryWorkingGroup::<Runtime>::ensure_worker_exists(current_lead_id)
  15. {
  16. *account_id == worker.role_account_id
  17. } else {
  18. false
  19. }
  20. } else {
  21. false
  22. }
  23. }
  24. fn is_curator(curator_id: &Self::CuratorId, account_id: &AccountId) -> bool {
  25. if let Ok(worker) =
  26. ContentDirectoryWorkingGroup::<Runtime>::ensure_worker_exists(curator_id)
  27. {
  28. *account_id == worker.role_account_id
  29. } else {
  30. false
  31. }
  32. }
  33. fn is_member(member_id: &Self::MemberId, account_id: &AccountId) -> bool {
  34. membership::Module::<Runtime>::ensure_is_controller_account_for_member(
  35. member_id, account_id,
  36. )
  37. .is_ok()
  38. }
  39. }