-
Notifications
You must be signed in to change notification settings - Fork 115
membership module #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/membership.rs
Outdated
| #[derive(Encode, Decode)] | ||
| pub struct Profile<T: Trait> { | ||
| id: T::MemberId, // is it necessary to have the id in the struct? | ||
| handle: u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| handle: u32, | |
| handle: Vec<u8>, |
src/membership.rs
Outdated
| id: T::MemberId, // is it necessary to have the id in the struct? | ||
| handle: u32, | ||
| avatarUri: Vec<u8>, | ||
| description: Vec<u8>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest naming this field as about such as description is a better word for items, but not a person
src/membership.rs
Outdated
|
|
||
| // Start at 1001? instead to reserve first 1000 ids ? | ||
| const FIRST_MEMBER_ID: u64 = 1; | ||
| const INITIAL_PAID_TERMS_ID: u64 = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistency in naming: FIRST_ vs INITIAL_
src/membership.rs
Outdated
| NextMemberId get(next_member_id) : T::MemberId = T::MemberId::sa(FIRST_MEMBER_ID); | ||
|
|
||
| /// Mapping of member ids to their corresponding accountid | ||
| MembersById get(members_by_id) : map T::MemberId => T::AccountId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MembersById get(members_by_id) : map T::MemberId => T::AccountId; | |
| AccountIdByMemberId get(account_id_by_member_id) : map T::MemberId => T::AccountId; |
src/membership.rs
Outdated
| MembersById get(members_by_id) : map T::MemberId => T::AccountId; | ||
|
|
||
| /// Mapping of members' accountid to their member id | ||
| MemberByAccount get(members_by_account) : map T::AccountId => T::MemberId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MemberByAccount get(members_by_account) : map T::AccountId => T::MemberId; | |
| MemberIdByAccountId get(member_id_by_account_id) : map T::AccountId => T::MemberId; |
src/membership.rs
Outdated
| ActivePaidMembershipTerms get(active_paid_membership_terms) : Vec<T::PaidTermId> = vec![T::PaidTermId::sa(INITIAL_PAID_TERMS_ID)]; | ||
|
|
||
| /// Is the platform is accepting new members or not | ||
| PlatformAcceptingNewMemberships get(platform_accepting_new_memberships) : bool = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| PlatformAcceptingNewMemberships get(platform_accepting_new_memberships) : bool = true; | |
| NewMembershipsAllowed get(new_memberships_allowed) : bool = true; |
src/membership.rs
Outdated
| pub enum Event<T> where | ||
| <T as system::Trait>::AccountId, | ||
| <T as Trait>::MemberId { | ||
| MemberAdded(MemberId, AccountId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to MemberRegistered? Registered sounds better when we think about users and social networks
src/membership.rs
Outdated
| handle: u32, | ||
| avatarUri: Vec<u8>, | ||
| description: Vec<u8>, | ||
| added: T::BlockNumber, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| added: T::BlockNumber, | |
| registeredAt: T::BlockNumber, |
src/membership.rs
Outdated
| pub struct Profile<T: Trait> { | ||
| id: T::MemberId, // is it necessary to have the id in the struct? | ||
| handle: u32, | ||
| avatarUri: Vec<u8>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option for a case if a user has not set their avatar.
| avatarUri: Vec<u8>, | |
| avatarUri: Option<Vec<u8>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decided on default empty vector == empty string to represent same as not setting avatar or about text. Also makes the batch updating logic simpler.. how to differentiate between user wanting to pass None to 'unset' avatar, or None as in they don't want to update the avatar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. In such case, it should be Option<Option<Vec<u8>>> and then if you want to set avatar_uri to None you will pass it with UserInfo as Some(None). And if you don't want to update it, then just None.
src/membership.rs
Outdated
| id: T::MemberId, // is it necessary to have the id in the struct? | ||
| handle: u32, | ||
| avatarUri: Vec<u8>, | ||
| description: Vec<u8>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option for a case if a user has not set their about - this is not required, yes?
| description: Vec<u8>, | |
| about: Option<Vec<u8>>, |
src/membership.rs
Outdated
|
|
||
| fn validate_avatar(uri: &Vec<u8>) -> Vec<u8> { | ||
| let mut uri = uri.clone(); | ||
| uri.truncate(Self::max_avatar_uri_length() as usize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that truncate is a good approach for avatar: if you truncate an URL then it became invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to limit the length somehow. We can accommodate a longer url upto 2000 ? https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as with a handle:
ensure!(uri.len() <= Self::max_avatar_uri_length() as usize, "avatar uri is too long");
|
Yeah interesting. Does parity-coded know how to encode Option<Option<T>>
and could it be implemented in polkadot-js-apps as custom type I wonder.
…On Fri, Mar 15, 2019 at 12:00 AM Alex Siman ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/membership.rs
<#3 (comment)>
:
> +pub trait Trait: system::Trait + GovernanceCurrency {
+ type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+
+ type MemberId: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64> + MaybeSerializeDebug;
+
+ type PaidTermId: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u32> + MaybeSerializeDebug;
+
+ type SubscriptionId: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u32> + MaybeSerializeDebug;
+}
+
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
+#[derive(Encode, Decode)]
+pub struct Profile<T: Trait> {
+ id: T::MemberId, // is it necessary to have the id in the struct?
+ handle: u32,
+ avatarUri: Vec<u8>,
Good question. In such case, it should be Option<Option<Vec<u8>>> and
then if you want to set avatar_uri to None you will pass it with UserInfo
as Some(None). And if you don't want to update it, then just None.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABi8FPdlzM4G-tUs5FUwrqhFWvGXJ2OVks5vWsZhgaJpZM4bspRq>
.
|
src/membership.rs
Outdated
| <Handles<T>>::remove(&profile.handle); | ||
| <Handles<T>>::insert(handle.clone(), profile.id); | ||
| profile.handle = handle; | ||
| <MemberProfile<T>>::insert(profile.id, profile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing an event MemberUpdatedHandle
src/membership.rs
Outdated
| Self::_change_member_handle(&who, handle)?; | ||
| } | ||
|
|
||
| fn batch_change_member_profile(origin, user_info: UserInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just update_profile?
| fn batch_change_member_profile(origin, user_info: UserInfo) { | |
| fn update_profile(origin, user_info: UserInfo) { |
Change ‘hiring’ module dependency version
Test pack #3 for Hiring Module
Add storage module+events
Update substrate
Upgrade libp2p
Introduce live milestons + various tweaks
Husky config
* NotFound translatable * Connecting overlay * Update rx-react (proper state management) * Use i18n-next everywhere * @flow updates
Joystream update membership roles
Content directory second try
File input to uploadVideo - suggested approach
Fix "Trying to access property id of undefined" (candidate.member.id)
Adding membership module.