Skip to content

Commit c855ee1

Browse files
committedApr 18, 2023
Fix: notifies validators on AnyCoordoDual contracts. Change: Add n_open_contracts meta field. Add new protected system username.
1 parent 86ededb commit c855ee1

File tree

5 files changed

+70
-7
lines changed

5 files changed

+70
-7
lines changed
 

‎CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ The commit name should starts with a name that identify the **type** of modifica
9090

9191
example: `fix/schema: Add color property to roles.`
9292

93-
Here are some common used for so called semantic commit message:
93+
Here are some common used for so called semantic commit message, which help to write releases notes from the git commit:
9494

9595
- feat: A new feature
9696
- fix: A bug fix
97+
- change: something changed (style, configuration, spec)
9798
- perf: A code change that improves performance
9899
- refactor: A code change that neither fixes a bug nor adds a feature
99100
- typo: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)

‎db/dql.go

+24
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,30 @@ var dqlQueries map[string]string = map[string]string{
150150
count(uid)
151151
}
152152
}`,
153+
"count_open_contracts_from_node": `{
154+
var(func: eq(Node.nameid, "{{.nameid}}")) {
155+
Node.source {
156+
Blob.tension {
157+
Tension.contracts @filter(eq(Contract.status, "Open")) {
158+
c as count(uid)
159+
}
160+
}
161+
}
162+
}
163+
all() {
164+
n_open_contracts: val(c)
165+
}
166+
}`,
167+
"count_open_contracts_from_tension": `{
168+
var(func: uid({{id}})) {
169+
Tension.contracts @filter(eq(Contract.status, "Open")) {
170+
c as count(uid)
171+
}
172+
}
173+
all() {
174+
n_open_contracts: val(c)
175+
}
176+
}`,
153177
"getOrgaAgg": `{
154178
var(func: eq(Node.nameid, "{{.nameid}}")) {
155179
Node.children @filter(eq(Node.role_type, "Guest")) {

‎graph/notifications.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,20 @@ func PushContractNotifications(notif model.ContractNotif) error {
272272
// Get relevant users for the contract
273273
users, err := GetUsersToNotify(notif.Tid, true, false, false)
274274
if err != nil { return err }
275+
if notif.Contract.ContractType == model.ContractTypeAnyCoordoDual &&
276+
notif.Contract.Event.EventType == model.TensionEventMoved && notif.Contract.Event.New != nil {
277+
// The contract is created inside the tension or the node to be moved.
278+
// But we also need to notidy users in the target circle.
279+
targetid := *notif.Contract.Event.New
280+
x, err := db.GetDB().GetSubSubFieldByEq("Node.nameid", targetid, "Node.source", "Blob.tension", "uid")
281+
if err != nil { return err }
282+
targetTid, _ := x.(string)
283+
users2, err := GetUsersToNotify(targetTid, true, false, false)
284+
if err != nil { return err }
285+
for k,v := range users2 {
286+
users[k] = v
287+
}
288+
}
275289
// +
276290
// Add Candidates
277291
for _, c := range notif.Contract.Candidates {
@@ -447,7 +461,7 @@ func PushNotifNotifications(notif model.NotifNotif, selfNotify bool) error {
447461
// User helpers
448462
//
449463

450-
// GetUserToNotify returns a list of user should receive notifications uponf tension updates.
464+
// GetUserToNotify returns a list of user that should receive notifications upon tension updates.
451465
// Note: order is important as for priority and emailing policy.
452466
func GetUsersToNotify(tid string, withAssignees, withSubscribers, withPeers bool) (map[string]model.UserNotifInfo, error) {
453467
users := make(map[string]model.UserNotifInfo)

‎graph/resolver.go

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ func private(ctx context.Context, obj interface{}, next graphql.Resolver) (inter
245245
return nil, fmt.Errorf("`%s' field is private", fieldName)
246246
}
247247

248+
// Use DQL query to fetch the given field=k.
249+
// If k is not given, "id" is automatically pass to the query template.
248250
func meta(ctx context.Context, obj interface{}, next graphql.Resolver, f string, k *string) (interface{}, error) {
249251
data, err:= next(ctx)
250252
if err != nil { return nil, err }

‎web/auth/validation.go

+27-5
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,49 @@ func init() {
8888
"api": true,
8989
"auth": true,
9090
"data": true,
91+
"assets": true,
9192
"static": true,
9293
"index": true,
9394
"index.html": true,
94-
// front
95+
"ghost": true,
96+
// front - about
97+
"about": true,
98+
"help": true,
99+
"features": true,
100+
"showcases": true,
101+
"marketplace": true,
102+
"solutions": true,
103+
"pricing": true,
104+
"trending": true,
105+
"topics": true,
106+
"manifesto": true,
107+
"sitemap": true,
108+
"enterprise": true,
109+
"collective": true,
110+
"developers": true,
111+
"terms-of-service": true,
112+
// front - app
113+
"home": true,
114+
"dashboard": true,
95115
"new": true, // tension, orga, networks
96116
"explore": true, // orgas, networks, users
97117
"login": true,
98118
"logout": true,
99119
"signup": true,
100120
"verification": true,
101121
"password-reset": true,
102-
"about": true,
103-
"help": true,
104-
"features": true,
105-
"showcase": true,
106122
"user": true,
107123
"users": true,
108124
"tension": true,
109125
"tensions": true,
126+
"project": true,
127+
"projects": true,
128+
"calendar": true,
129+
"calendars": true,
110130
"org": true,
131+
"orgs": true,
111132
"network": true,
133+
"networks": true,
112134
}
113135
}
114136

0 commit comments

Comments
 (0)
Please sign in to comment.