Преглед изворни кода

Content: introduce ensure_actor_authorized_to_set_featured_videos check

iorveth пре 4 година
родитељ
комит
5cdfc15b59
2 измењених фајлова са 15 додато и 3 уклоњено
  1. 1 3
      runtime-modules/content/src/lib.rs
  2. 14 0
      runtime-modules/content/src/permissions/mod.rs

+ 1 - 3
runtime-modules/content/src/lib.rs

@@ -1215,11 +1215,9 @@ decl_module! {
             list: Vec<T::VideoId>
         ) {
             // can only be set by lead
-            ensure_actor_authorized_update_channel_and_videos::<T>(
+            ensure_actor_authorized_to_set_featured_videos::<T>(
                 origin,
                 &actor,
-                // The channel owner will be..
-                &Self::actor_to_channel_owner(&actor)?,
             )?;
 
             Self::ensure_videos_exist(&list)?;

+ 14 - 0
runtime-modules/content/src/permissions/mod.rs

@@ -182,6 +182,20 @@ pub fn ensure_actor_authorized_update_channel_and_videos<T: Trait>(
     }
 }
 
+// Enure actor can update or delete channels and videos
+pub fn ensure_actor_authorized_to_set_featured_videos<T: Trait>(
+    origin: T::Origin,
+    actor: &ContentActor<T::CuratorGroupId, T::CuratorId, T::MemberId>,
+) -> DispatchResult {
+    // Only Lead authorized to set featured videos
+    if let ContentActor::Lead = actor {
+        let sender = ensure_signed(origin)?;
+        ensure_lead_auth_success::<T>(&sender)
+    } else {
+        Err(Error::<T>::ActorNotAuthorized.into())
+    }
+}
+
 pub fn ensure_actor_authorized_to_censor<T: Trait>(
     origin: T::Origin,
     actor: &ContentActor<T::CuratorGroupId, T::CuratorId, T::MemberId>,