Skip to content

Commit

Permalink
Merge pull request #636 from ethereum-push-notification-service/updat…
Browse files Browse the repository at this point in the history
…e-guild-examples
  • Loading branch information
HarshRajat authored Mar 13, 2024
2 parents dee38ba + b077a6e commit d1f4826
Showing 1 changed file with 66 additions and 82 deletions.
148 changes: 66 additions & 82 deletions docs/chat/01-build/10-Develop-Conditional-Rule-For-Groups.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -522,30 +522,29 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
private: false, // in our case, we are making a public group
rules: {
entry: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
{
any: [
all: [
// this criteria lets admins or owners invite anyone
{
// criteria 1
// this criteria lets admins or owners invite anyone
type: "PUSH",
category: "INVITE",
subcategory: "DEFAULT",
data: {
inviterRoles: ["ADMIN", "OWNER"],
},
},

],
},
{
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
id: "sniper-fam", // your guild id or guild URL name
comparison: "any", // in our case, we are allowing if user has atleast one role in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its any role so we are using *
},
Expand Down Expand Up @@ -594,32 +593,31 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
private: false, // in our case, we are making a public group
rules: {
entry: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
{
any: [
all: [
// this criteria lets admins or owners invite anyone
{
// criteria 1
// this criteria lets admins or owners invite anyone
type: "PUSH",
category: "INVITE",
subcategory: "DEFAULT",
data: {
inviterRoles: ["ADMIN", "OWNER"],
},
},

],
},
{
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
comparison: "all", // in our case, we are allowing if user has atleast one role in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its all roles so we are using *
id: "sniper-fam", // your guild id or guild URL name
comparison: "all", // in our case, we are allowing only if user has all the roles in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its any role so we are using *
},
},
],
Expand Down Expand Up @@ -666,32 +664,30 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
private: false, // in our case, we are making a public group
rules: {
entry: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
{
any: [
all: [
{
// criteria 1
// this criteria lets admins or owners invite anyone
type: "PUSH",
category: "INVITE",
subcategory: "DEFAULT",
data: {
inviterRoles: ["ADMIN", "OWNER"],
},
},

],
},
{
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
comparison: "all", // in our case, we are allowing if user has atleast one role in the guild mentioned above
role: "111070", // id of the specific role in guild that you want to allow
id: "sniper-fam", // your guild id or guild URL name
comparison: "", // in our case, its targetting a specific role so we are leaving it empty
role: "discord fellow", // role name or role id that you want to target
},
},
],
Expand Down Expand Up @@ -740,32 +736,31 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
private: false, // in our case, we are making a public group
rules: {
entry: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
all: [
{
any: [
all: [
// this criteria lets admins or owners invite anyone
{
// criteria 1
// this criteria lets admins or owners invite anyone
type: "PUSH",
category: "INVITE",
subcategory: "DEFAULT",
data: {
inviterRoles: ["ADMIN", "OWNER"],
},
},

],
},
{
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
id: "sniper-fam", // your guild id or guild URL name
comparison: "any", // in our case, we are allowing if user has atleast one role in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its any role so we are using *
role: "*", // useful when you want to target a specific role but in our case, its all roles so we are using *
},
},
],
Expand All @@ -774,21 +769,18 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
},
},
chat: {
// chatting permission is based on conditions
conditions: {
any: [
// any of the decider should allow user to send message in the group
all: [
{
any: [
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
id: "sniper-fam", // your guild id or guild URL name
comparison: "any", // in our case, we are allowing if user has atleast one role in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its any role so we are using *
role: "*", // useful when you want to target a specific role but in our case, its all roles so we are using *
},
},
],
Expand Down Expand Up @@ -835,31 +827,30 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
private: false, // in our case, we are making a public group
rules: {
entry: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
all: [
{
any: [
all: [
// this criteria lets admins or owners invite anyone
{
// criteria 1
// this criteria lets admins or owners invite anyone
type: "PUSH",
category: "INVITE",
subcategory: "DEFAULT",
data: {
inviterRoles: ["ADMIN", "OWNER"],
},
},

],
},
{
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
comparison: "all", // in our case, we are allowing if user has atleast one role in the guild mentioned above
id: "sniper-fam", // your guild id or guild URL name
comparison: "all", // in our case, we are allowing only if user has all the roles in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its all roles so we are using *
},
},
Expand All @@ -869,21 +860,18 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
},
},
chat: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
all: [
{
any: [
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
comparison: "all", // in our case, we are allowing if user has atleast one role in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its any role so we are using *
id: "sniper-fam", // your guild id or guild URL name
comparison: "all", // in our case, we are allowing only if user has all the roles in the guild mentioned above
role: "*", // useful when you want to target a specific role but in our case, its all roles so we are using *
},
},
],
Expand Down Expand Up @@ -930,32 +918,31 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
private: false, // in our case, we are making a public group
rules: {
entry: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
all: [
{
any: [
all: [
// this criteria lets admins or owners invite anyone
{
// criteria 1
// this criteria lets admins or owners invite anyone
type: "PUSH",
category: "INVITE",
subcategory: "DEFAULT",
data: {
inviterRoles: ["ADMIN", "OWNER"],
},
},

],
},
{
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
comparison: "", // in our case, we are allowing if user has specific role so no comparison needed
role: "111070", // id of the specific role in guild that you want to allow
id: "sniper-fam", // your guild id or guild URL name
comparison: "", // in our case, its targetting a specific role so we are leaving it empty
role: "discord fellow", // role name or role id that you want to target, not case sensitive
},
},
],
Expand All @@ -964,21 +951,18 @@ const createGuildGatedGroup = await userAlice.chat.group.create(
},
},
chat: {
// entry is based on conditions
conditions: {
any: [
// any of the decider should allow entry
all: [
{
any: [
all: [
{
// define criteria 2
type: "GUILD", // define type that rules engine should go for, currently supports PUSH or GUILD
category: "ROLES", // define it's ROLES for GUILD groups
subcategory: "DEFAULT", // its DEFAULT for GUILD groups
data: {
id: "62154", // your guild id
comparison: "", // in our case, we are allowing if user has specific role so no comparison needed
role: "111070", // id of the specific role in guild that you want to allow
id: "sniper-fam", // your guild id or guild URL name
comparison: "", // in our case, its targetting a specific role so we are leaving it empty
role: "discord fellow", // role name or role id that you want to target, not case sensitive
},
},
],
Expand Down

0 comments on commit d1f4826

Please sign in to comment.