Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
/// Update category
fn update_category(origin, category_id: CategoryId, new_archival_status: Option<bool>, new_deletion_status: Option<bool>) -> dispatch::Result {
// Check that its a valid signature
let who = ensure_signed(origin)?;
// Not signed by forum SUDO
// Get path from parent to root of category tree.
let category_tree_path = Self::ensure_valid_category_and_build_category_tree_path(category_id)?;
// Make sure we can actually mutate this category
// Mutate category, and set possible new change parameters
let mut category = Self::category_by_id(category_id).ok_or("Category was not found by id")?;
let mut changes_count = 0;
if let Some(archived) = new_archival_status {
if category.archived != archived {
category.archived = archived;
if let Some(deleted) = new_deletion_status {
if category.deleted != deleted {
category.deleted = deleted;
if changes > 0 {
<CategoryById<T>>::insert(post_id, category);
// Generate event
Self::deposit_event(RawEvent::CategoryUpdated(category_id, new_archival_status, new_deletion_status));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.