Skip to content

Conversation

@mnaamani
Copy link
Member

@mnaamani mnaamani commented Mar 13, 2019

Adding membership module.

#[derive(Encode, Decode)]
pub struct Profile<T: Trait> {
id: T::MemberId, // is it necessary to have the id in the struct?
handle: u32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handle: u32,
handle: Vec<u8>,

id: T::MemberId, // is it necessary to have the id in the struct?
handle: u32,
avatarUri: Vec<u8>,
description: Vec<u8>,
Copy link
Contributor

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


// Start at 1001? instead to reserve first 1000 ids ?
const FIRST_MEMBER_ID: u64 = 1;
const INITIAL_PAID_TERMS_ID: u64 = 1;
Copy link
Contributor

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_

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MembersById get(members_by_id) : map T::MemberId => T::AccountId;
AccountIdByMemberId get(account_id_by_member_id) : map T::MemberId => T::AccountId;

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MemberByAccount get(members_by_account) : map T::AccountId => T::MemberId;
MemberIdByAccountId get(member_id_by_account_id) : map T::AccountId => T::MemberId;

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PlatformAcceptingNewMemberships get(platform_accepting_new_memberships) : bool = true;
NewMembershipsAllowed get(new_memberships_allowed) : bool = true;

pub enum Event<T> where
<T as system::Trait>::AccountId,
<T as Trait>::MemberId {
MemberAdded(MemberId, AccountId),
Copy link
Contributor

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

handle: u32,
avatarUri: Vec<u8>,
description: Vec<u8>,
added: T::BlockNumber,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
added: T::BlockNumber,
registeredAt: T::BlockNumber,

pub struct Profile<T: Trait> {
id: T::MemberId, // is it necessary to have the id in the struct?
handle: u32,
avatarUri: Vec<u8>,
Copy link
Contributor

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.

Suggested change
avatarUri: Vec<u8>,
avatarUri: Option<Vec<u8>>,

Copy link
Member Author

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

Copy link
Contributor

@siman siman Mar 14, 2019

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.

id: T::MemberId, // is it necessary to have the id in the struct?
handle: u32,
avatarUri: Vec<u8>,
description: Vec<u8>,
Copy link
Contributor

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?

Suggested change
description: Vec<u8>,
about: Option<Vec<u8>>,


fn validate_avatar(uri: &Vec<u8>) -> Vec<u8> {
let mut uri = uri.clone();
uri.truncate(Self::max_avatar_uri_length() as usize);
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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");

@mnaamani
Copy link
Member Author

mnaamani commented Mar 14, 2019 via email

@mnaamani mnaamani marked this pull request as ready for review March 15, 2019 08:58
<Handles<T>>::remove(&profile.handle);
<Handles<T>>::insert(handle.clone(), profile.id);
profile.handle = handle;
<MemberProfile<T>>::insert(profile.id, profile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing an event MemberUpdatedHandle

Self::_change_member_handle(&who, handle)?;
}

fn batch_change_member_profile(origin, user_info: UserInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just update_profile?

Suggested change
fn batch_change_member_profile(origin, user_info: UserInfo) {
fn update_profile(origin, user_info: UserInfo) {

@mnaamani mnaamani changed the title adding membership module - storage membership module Mar 16, 2019
@mnaamani mnaamani mentioned this pull request Mar 23, 2019
3 tasks
@bwhm bwhm added this to the Finalize runtime for internal Athens Runtime Testnet milestone Mar 23, 2019
@siman siman merged commit b592639 into Joystream:development Mar 25, 2019
bedeho pushed a commit that referenced this pull request Feb 24, 2020
Change ‘hiring’ module dependency version
shamil-gadelshin referenced this pull request in shamil-gadelshin/joystream-network Mar 9, 2020
shamil-gadelshin referenced this pull request in shamil-gadelshin/joystream-network Mar 9, 2020
Add storage module+events
shamil-gadelshin referenced this pull request in shamil-gadelshin/joystream-network Mar 9, 2020
shamil-gadelshin referenced this pull request in shamil-gadelshin/joystream-network Mar 9, 2020
shamil-gadelshin referenced this pull request in shamil-gadelshin/joystream-network Mar 9, 2020
bedeho pushed a commit that referenced this pull request Apr 16, 2020
Introduce live milestons + various tweaks
bedeho pushed a commit that referenced this pull request Apr 16, 2020
semeano added a commit to semeano/joystream that referenced this pull request May 14, 2020
Lezek123 referenced this pull request in Lezek123/substrate-runtime-joystream May 21, 2020
* NotFound translatable

* Connecting overlay

* Update rx-react (proper state management)

* Use i18n-next everywhere

* @flow updates
@mnaamani mnaamani deleted the membership branch May 22, 2020 20:32
bedeho pushed a commit that referenced this pull request May 29, 2020
gleb-urvanov referenced this pull request in gleb-urvanov/substrate-runtime-joystream Aug 21, 2020
DzhideX pushed a commit to DzhideX/joystream that referenced this pull request Sep 10, 2020
shamil-gadelshin pushed a commit that referenced this pull request Sep 16, 2020
bwhm referenced this pull request in bwhm/joystream Dec 2, 2020
File input to uploadVideo - suggested approach
shamil-gadelshin pushed a commit that referenced this pull request Apr 4, 2021
mnaamani pushed a commit that referenced this pull request Aug 11, 2021
Lezek123 pushed a commit that referenced this pull request Dec 16, 2021
Fix "Trying to access property id of undefined" (candidate.member.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants