|
@@ -68,7 +68,7 @@ pub trait WeightInfo {
|
|
|
fn delete_category_lead(i: u32) -> Weight;
|
|
|
fn delete_category_moderator(i: u32) -> Weight;
|
|
|
fn create_thread(j: u32, k: u32, i: u32) -> Weight;
|
|
|
- fn edit_thread_title(i: u32, j: u32) -> Weight;
|
|
|
+ fn edit_thread_metadata(i: u32, j: u32) -> Weight;
|
|
|
fn delete_thread(i: u32) -> Weight;
|
|
|
fn move_thread_to_category_lead(i: u32) -> Weight;
|
|
|
fn move_thread_to_category_moderator(i: u32) -> Weight;
|
|
@@ -263,8 +263,8 @@ pub struct Post<ForumUserId, ThreadId, Hash, Balance, BlockNumber> {
|
|
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
|
|
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug, Eq)]
|
|
|
pub struct Thread<ForumUserId, CategoryId, Moment, Hash, Balance> {
|
|
|
- /// Title hash
|
|
|
- pub title_hash: Hash,
|
|
|
+ /// Metadata hash
|
|
|
+ pub metadata_hash: Hash,
|
|
|
|
|
|
/// Category in which this thread lives
|
|
|
pub category_id: CategoryId,
|
|
@@ -536,8 +536,8 @@ decl_event!(
|
|
|
/// The second argument reflects the new archival status of the thread.
|
|
|
ThreadUpdated(ThreadId, bool, PrivilegedActor, CategoryId),
|
|
|
|
|
|
- /// A thread with given id was moderated.
|
|
|
- ThreadTitleUpdated(ThreadId, ForumUserId, CategoryId, Vec<u8>),
|
|
|
+ /// A thread metadata given id was updated.
|
|
|
+ ThreadMetadataUpdated(ThreadId, ForumUserId, CategoryId, Vec<u8>),
|
|
|
|
|
|
/// A thread was deleted.
|
|
|
ThreadDeleted(ThreadId, ForumUserId, CategoryId, bool),
|
|
@@ -898,7 +898,7 @@ decl_module! {
|
|
|
/// - O(W)
|
|
|
/// # </weight>
|
|
|
#[weight = WeightInfoForum::<T>::create_thread(
|
|
|
- title.len().saturated_into(),
|
|
|
+ metadata.len().saturated_into(),
|
|
|
text.len().saturated_into(),
|
|
|
T::MaxCategoryDepth::get() as u32,
|
|
|
)]
|
|
@@ -906,7 +906,7 @@ decl_module! {
|
|
|
origin,
|
|
|
forum_user_id: ForumUserId<T>,
|
|
|
category_id: T::CategoryId,
|
|
|
- title: Vec<u8>,
|
|
|
+ metadata: Vec<u8>,
|
|
|
text: Vec<u8>,
|
|
|
poll_input: Option<PollInput<T::Moment>>,
|
|
|
) -> DispatchResult {
|
|
@@ -947,7 +947,7 @@ decl_module! {
|
|
|
// Build a new thread
|
|
|
let new_thread = Thread {
|
|
|
category_id,
|
|
|
- title_hash: T::calculate_hash(&title),
|
|
|
+ metadata_hash: T::calculate_hash(&metadata),
|
|
|
author_id: forum_user_id,
|
|
|
poll,
|
|
|
cleanup_pay_off: T::ThreadDeposit::get(),
|
|
@@ -981,7 +981,7 @@ decl_module! {
|
|
|
new_thread_id,
|
|
|
initial_post_id,
|
|
|
forum_user_id,
|
|
|
- title,
|
|
|
+ metadata,
|
|
|
text,
|
|
|
poll_input,
|
|
|
)
|
|
@@ -1001,11 +1001,17 @@ decl_module! {
|
|
|
/// - DB:
|
|
|
/// - O(W)
|
|
|
/// # </weight>
|
|
|
- #[weight = WeightInfoForum::<T>::edit_thread_title(
|
|
|
+ #[weight = WeightInfoForum::<T>::edit_thread_metadata(
|
|
|
T::MaxCategoryDepth::get() as u32,
|
|
|
- new_title.len().saturated_into(),
|
|
|
+ new_metadata.len().saturated_into(),
|
|
|
)]
|
|
|
- fn edit_thread_title(origin, forum_user_id: ForumUserId<T>, category_id: T::CategoryId, thread_id: T::ThreadId, new_title: Vec<u8>) -> DispatchResult {
|
|
|
+ fn edit_thread_metadata(
|
|
|
+ origin,
|
|
|
+ forum_user_id: ForumUserId<T>,
|
|
|
+ category_id: T::CategoryId,
|
|
|
+ thread_id: T::ThreadId,
|
|
|
+ new_metadata: Vec<u8>
|
|
|
+ ) -> DispatchResult {
|
|
|
// Ensure data migration is done
|
|
|
Self::ensure_data_migration_done()?;
|
|
|
|
|
@@ -1017,17 +1023,17 @@ decl_module! {
|
|
|
// == MUTATION SAFE ==
|
|
|
//
|
|
|
|
|
|
- // Update thread title
|
|
|
- let title_hash = T::calculate_hash(&new_title);
|
|
|
- <ThreadById<T>>::mutate(thread.category_id, thread_id, |thread| thread.title_hash = title_hash);
|
|
|
+ // Update thread metadata
|
|
|
+ let metadata_hash = T::calculate_hash(&new_metadata);
|
|
|
+ <ThreadById<T>>::mutate(thread.category_id, thread_id, |thread| thread.metadata_hash = metadata_hash);
|
|
|
|
|
|
// Store the event
|
|
|
Self::deposit_event(
|
|
|
- RawEvent::ThreadTitleUpdated(
|
|
|
+ RawEvent::ThreadMetadataUpdated(
|
|
|
thread_id,
|
|
|
forum_user_id,
|
|
|
category_id,
|
|
|
- new_title,
|
|
|
+ new_metadata,
|
|
|
)
|
|
|
);
|
|
|
|