Skip to content

Commit

Permalink
Add force_follow_space to space-follows pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
F3Joule committed Jul 22, 2022
1 parent 963a63c commit 09506c7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pallets/space-follows/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ pub mod pallet {

Self::unfollow_space_by_account(follower, space_id)
}

#[pallet::weight((
100_000 + T::DbWeight::get().reads_writes(3, 4),
DispatchClass::Operational,
Pays::Yes,
))]
pub fn force_follow_space(
origin: OriginFor<T>,
follower: T::AccountId,
space_id: SpaceId,
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;

SpaceFollowers::<T>::mutate(space_id, |followers| followers.push(follower.clone()));
SpaceFollowedByAccount::<T>::insert((follower.clone(), space_id), true);
SpacesFollowedByAccount::<T>::mutate(follower.clone(), |space_ids| {
space_ids.push(space_id)
});

Self::deposit_event(Event::SpaceFollowed(follower, space_id));

Ok(Pays::No.into())
}
}

impl<T: Config> Pallet<T> {
Expand Down

0 comments on commit 09506c7

Please sign in to comment.