Skip to content

Commit 385c235

Browse files
feat(gno/dao): add social feed message create post daokit for govdao (#1509)
1 parent 3b437af commit 385c235

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

gno/p/basedao/render.gno

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
PROPOSAL_HISTORY_PATH = "history"
1717
MEMBER_DETAIL_PATH = "member/{address}"
1818
PROPOSAL_DETAIL_PATH = "proposal/{id}"
19-
FALLBACK_DISPLAY_NAME = "Anon"
19+
FALLBACK_DISPLAY_NAME = "Anon"
2020
)
2121

2222
func (d *DAO) initRenderingRouter() {

gno/r/govdao/govdao.gno

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"gno.land/p/teritori/role_manager"
88
"gno.land/r/demo/profile"
99
"gno.land/r/teritori/ghverify"
10+
"gno.land/r/teritori/social_feeds"
1011
)
1112

1213
const (
@@ -32,9 +33,6 @@ func init() {
3233
{Address: "g126gx6p6d3da4ymef35ury6874j6kys044r7zlg", Roles: []string{Tier1}},
3334
{Address: "g1ld6uaykyugld4rnm63rcy7vju4zx23lufml3jv", Roles: []string{Tier2}},
3435
{Address: "g1r69l0vhp7tqle3a0rk8m8fulr8sjvj4h7n0tth", Roles: []string{Tier2}},
35-
{Address: "g1ns5vfj5app8sqqgc5jzst79rmahws8p9asfryd", Roles: []string{Tier3}},
36-
{Address: "g1jkfwvm7pxr65r75tnyzt0s8k6cfjjdh7533q35", Roles: []string{Tier3}},
37-
{Address: "g16jv3rpz7mkt0gqulxas56se2js7v5vmc6n6e0r", Roles: []string{Tier3}},
3836
}
3937
dao = basedao.New(&basedao.Config{
4038
Name: "GovDAO",
@@ -48,6 +46,7 @@ func init() {
4846
Members: basedao.NewMembersStore(initialRoles, initialMembers),
4947
SetProfileString: profile.SetStringField,
5048
GetProfileString: profile.GetStringField,
49+
NoEvents: true,
5150
})
5251

5352
// XXX: t1Supermajority won't work because daocond.RoleThreshold uses events
@@ -68,6 +67,10 @@ func init() {
6867
Handler: basedao.NewEditProfileHandler(profile.SetStringField, nil),
6968
Condition: supermajority,
7069
},
70+
{
71+
Handler: social_feeds.NewCreatePostDaokitHandler(),
72+
Condition: supermajority,
73+
},
7174
}
7275
for _, r := range resources {
7376
dao.Core.SetResource(r)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package social_feeds
2+
3+
import (
4+
"gno.land/p/demo/ufmt"
5+
"gno.land/p/teritori/daokit"
6+
)
7+
8+
const MsgCreatePostDaokitKind = "gno.land/r/teritori/social_feeds.CreatePost"
9+
10+
type MsgCreatePostDaokit struct {
11+
FeedID FeedID
12+
ParentID PostID
13+
Category uint64
14+
Metadata string
15+
}
16+
17+
func (m *MsgCreatePostDaokit) String() string {
18+
buf := ""
19+
buf += ufmt.Sprintf("Create post in feed %s", m.FeedID.String())
20+
if m.ParentID != 0 {
21+
buf += ufmt.Sprintf(" as a reply to post %s", m.ParentID.String())
22+
}
23+
buf += ufmt.Sprintf(" with category %d", m.Category)
24+
buf += ufmt.Sprintf(" and metadata %s", m.Metadata)
25+
return buf
26+
}
27+
28+
func NewCreatePostDaokitHandler() daokit.MessageHandler {
29+
return daokit.NewMessageHandler(MsgCreatePostDaokitKind, func(msg interface{}) {
30+
message := msg.(*MsgCreatePostDaokit)
31+
CreatePost(message.FeedID, message.ParentID, message.Category, message.Metadata)
32+
})
33+
}
34+
35+
func NewCreatePostDaokitMsg(payload *MsgCreatePostDaokit) daokit.ExecutableMessage {
36+
return daokit.NewMessage(MsgCreatePostDaokitKind, payload)
37+
}

0 commit comments

Comments
 (0)