NEAR-DevHub / neardevhub-contract

DevHub Portal Product Contract (Hosted on NEAR Blockchain) – Includes other instances (e.g. Infrastructure, Events)
https://neardevhub.org
19 stars 15 forks source link

Community Metadata #75

Closed elliotBraem closed 11 months ago

elliotBraem commented 11 months ago

This is related to #491 Editing community leads to a 400 error message as a possible solution.

Assuming a completed #74, below is the effective Community Struct:

pub struct Community {
    pub admins: Vec<AccountId>,
    pub handle: CommunityHandle,
    pub name: String,
    pub tag: String,
    pub description: String,
    pub logo_url: String,
    pub banner_url: String,
    pub bio_markdown: Option<String>,
    pub github_handle: Option<String>,
    pub telegram_handle: Vec<String>,
    pub twitter_handle: Option<String>,
    pub website_url: Option<String>,
    pub addons: Vec<CommunityAddOn>,
}

Currently, there is an issue when we are updating communities that the payload is too large. This is because our only available update_community function will update the entire community at a time (including all of the addons and their data). This payload is too large for the wallet redirect and so transactions are failing.

A way to fix this is splitting the available update functions, I'm thinking:

And in this migration to metadata, I would propose that we reflect the social contract metadata standard more:

pub struct Community {
    pub handle: CommunityHandle, <-- currently this is editable, I do not think it should be
    pub admins: Vec<AccountId>,
    pub metadata: CommunityMetadata,
    pub addons: Vec<CommunityAddOn>,
}

pub struct CommunityMetadata {
    pub name: String,
    pub description: String,
    pub image: String, 
    pub backgroundImage: String,
    pub linktree: Vec<String>    <--- Key value pairs, could be stringified objects or looking for suggestions
    pub tags: Vec<String>,
    pub bio: String
}

Splitting into these functions should solve the issue, as well as more closely reflecting social db metadata standards will enable template swapping and more widget support, such as mob.near/widget/Image, the metadata editor, and more.


Note:

It seems that there had been an attempt to use CommunityMetadata before; although these remnant's exist in the code, they are not used besides in get_community_metadata and get_all_communities_metadata, although it's only an object to be mapped to.

Accepting this change will require several changes on the front end to use the revised structure and functions.

Tguntenaar commented 11 months ago

@ori-near I noticed we are making a difference between bio_markdown and description right now, which I'm not sure why. In the social contract metadata standard description is also a string in markdown format.

I've looked at a few communities and the once I saw are repeating more or less the same message in these fields. By the way, bio_markdown is visible in the sidebar on the activity tab.

For now, I will store it in the Community struct instead of the metadata @elliotBraem.

Tguntenaar commented 11 months ago

Hey @elliotBraem, I just discussed with @frol that restructuring the community metadata will be double work since this will also be fixed by #540.

Also splitting up the update_community funciton is not effective for issue #491. This is because set_community_addons is already been split up and will give the error as well. We will have to wait untill the old wallet is deprecated.

Updating the addons name can be done from the addons configurator directly. But currently, the order of the addons won't be able to change in chases where the vector of addons is already too big in size.

So this issue can be closed.

frol commented 11 months ago

Just to clarify, after https://github.com/near/neardevhub-widgets/issues/540 we should just set the metadata to SocialDB.