community.gno
2.56 Kb · 71 lines
1package community
2
3import (
4 zenaov1 "gno.land/p/zenao/zenao/v1"
5 "gno.land/p/zenao/communities"
6 "gno.land/p/zenao/basedao"
7 "gno.land/p/zenao/daokit"
8 "gno.land/p/zenao/daocond"
9 "gno.land/r/demo/profile"
10 "gno.land/r/zenao/communityreg"
11 "gno.land/r/zenao/social_feed"
12)
13
14var (
15 DAO daokit.DAO
16 localDAO daokit.DAO
17
18 community *communities.Community // XXX: needed for backward compatibility with frontend queries
19 feedId string // XXX: workaround for "unexpected zero object id" issue
20)
21
22func init() {
23 // XXX: workaround for "unexpected zero object id" issue
24 feedId = social_feed.NewFeed(cross, "main", false, feedAuth)
25}
26
27func init() {
28 conf := communities.Config{
29 ZenaoAdminAddr: "g1djrkw9tf4px658j85cc6fhsvm50uf9s0g6kfsm",
30 Administrators: []string{"gno.land/r/zenao/users/u376"},
31 Members: []string{"gno.land/r/zenao/users/u376", "gno.land/r/zenao/users/u377", "gno.land/r/zenao/users/u376"},
32 Events: []string{"gno.land/r/zenao/events/e60"},
33 DisplayName: "Bibliothèque de Livres Vivants à la Médiathèque Alain Gérard de Quimper",
34 Description: "Vous souhaitez écouter des témoignages de personnes concernées par un trouble psychique ? Devenez lecteur de livres vivants et luter contre la stigmatisation !\n\nRendez-vous le mercredi 15 octobre à la Bibliothèque universitaire des Lettres de Brest pour écouter les Livres Vivants qui partageront leurs tranches de vie.\n\nC'est Gratuit !\n\n- 💬 Bibliothèque de Livres Vivants\n- 📆 Samedi 18 octobre 2025, de 13h30 à 15h30.\n- 📍Médiathèque Alain Gérard Quimper",
35 AvatarURI: "ipfs://bafkreieqj4jm5azd3asyyh37372v34o6pekk2atiswt5krwuu42iorns5m",
36 BannerURI: "",
37 GetProfileString: profile.GetStringField,
38 SetProfileString: profile.SetStringField,
39 CrossFn: crossFn,
40 SetImplemFn: setImplem,
41 FeedId: feedId,
42 PrivateVarName: "community",
43 }
44 community = communities.NewCommunity(&conf)
45 communityreg.Register(cross, func() *zenaov1.CommunityInfo { return community.Info() })
46}
47
48func Vote(_ realm, proposalID uint64, vote daocond.Vote) {
49 localDAO.Vote(proposalID, vote)
50}
51
52func Execute(_ realm, proposalID uint64) {
53 localDAO.Execute(proposalID)
54}
55
56func Render(path string) string {
57 return localDAO.Render(path)
58}
59
60func feedAuth() (string, bool) {
61 caller := community.DAOPrivate.CallerID() // XXX: this should be upgradable
62 return caller, basedao.MustGetMembersViewExtension(localDAO).IsMember(caller)
63}
64
65func crossFn(_ realm, cb func()) {
66 cb()
67}
68
69func setImplem(newLocalDAO daokit.DAO, newDAO daokit.DAO) {
70 localDAO, DAO = newLocalDAO, newDAO
71}