Skip to content

Commit

Permalink
Join group option (#681)
Browse files Browse the repository at this point in the history
* feat: created architechture

* fix: added context values (#594)

* Chat dataprovider (#596)

* feat: data provider for chat component

* fix: replaced react.usestate to usestate

* fix: added props as the initial state and changed state name

* fix: reverted chat context changes and renamed values

* fix: added test page for chat ui components (#597)

* added chatbubble component (#602)

* feat: added chatbubble component

* fix: made the messageBubble's width to fit-content

---------

Co-authored-by: Monalisha Mishra <42746736+mishramonalisha76@users.noreply.github.com>

* fix: added theme

* Group chat bubble (#604)

* feat: moved test component to testui folder & replaced dummy data with sdk response

* feat: added twitter card and address for group chat received msg

* feat: made the messageaddress reusable, added account from context

* fix: removed unnecessary div and unused props and console logs

* feat: adding pfp in text bubbles

* fix: replaced hook with function and added pfp to messagebubble

* fix: fixed image alignment

* fix: changed border-radius of msg bubble and changed function name

* fix: fixed theme and decryptedPrivateKey name (#616)

* fix: fixed theme and decryptedPrivateKey name

* fix: fixed bug

* fix: fixed theme reviews

* Message list (#615)

* fix: message list comp

* fix: message list comp

* fix: added pagination

* fix: added pagination

* fix: pagination

* fix: create useChatData hook

* fix: fixed minor bug

* fix: socket issues fixed

* fix: added theme in msgbubble (#620)

* fix: added theme in msgbubble

* fix: fixed import

---------

Co-authored-by: Monalisha Mishra <mishramonalisha76@gmail.com>

* fix: exported the theme (#623)

* fix: exported the theme

* fix: fixed issues

---------

Co-authored-by: Monalisha Mishra <mishramonalisha76@gmail.com>

* Typebar component (#631)

* feat: added typebar UI

* feat: added functions to typebar

* fix: added icon

* fix: fixed theme issues

---------

Co-authored-by: Monalisha Mishra <mishramonalisha76@gmail.com>

* feat: added connectbutton

* fix: fixed connectbtn ui and remove disconnect and fixed error on disconnect

* fix: fixed create account getting called twice

* Profile Header Component (#636)

* feat: profile header

* feat: update profile header

* fix: update hooks

* fix: video icon ui

* feat: add group modal

* fix: add modal info

* fix: edit components

* fix: commit modal theme

* fix: updating UI

* fix: ensname

* fix: add notifs

* fix: remove alerts

* fix: remove alert logs

* fix: push fixes

* fix: conflicts

* Message container (#635)

* fix: added theme in msgbubble

* fix: fixed import

* fix: fixed message-list

* fix: added approve intent

* fix: added fixes

* fix: fixed socket bug

* fix: fixed message from socket

* fix: fixed minor issues

* fix: fixed typebar theming

* fix: fixed env issue

* fix: fixed message not updating issue

* refactor: added isConnected prop in msgContainer

* refactor: resolve merge conflicts

* fix: fixed request sending

* fix: fixed decryption

* fix: fixed env issue

* feat: added profile header in message container

---------

Co-authored-by: KlausMikhaelson <satyamsingh5076@gmail.com>
Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>

* fix: updated svg to react component

* fix: changed svg to tsx component

* fix: fixed review changes (#646)

* fix: fixed review changes

* fix: resolved issues

---------

Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>

* Profile Header -> Chat Profile fixes (#647)

* feat: profile header

* feat: update profile header

* fix: update hooks

* fix: video icon ui

* feat: add group modal

* fix: add modal info

* fix: edit components

* fix: commit modal theme

* fix: updating UI

* fix: ensname

* fix: add notifs

* fix: remove alerts

* fix: remove alert logs

* fix: push fixes

* fix: conflicts

* fix: notifs

* fix: correct theme colors

* fix: renaming profileHeader

* fix: qa fixes

* fix: loader

* refactor: resolved issues

* fix: edit types

---------

Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>

* fix: resolved package not added issue

* Fix: modal issue in group info && alert remove members (#653)

* fix: modal

* fix: update changes

* refactor: resolved issue

---------

Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>

* fix: QA fixes (#654)

* fix: fixed typebar space not working and theme

* feat: created access control UI

* feat: created verify access control hook

* Connect btn revamp (#668)

* fix: added theme in msgbubble

* fix: fixed import

* fix: fixed message-list

* fix: added approve intent

* fix: added fixes

* fix: fixed socket bug

* fix: fixed message from socket

* fix: fixed minor issues

* fix: fixed typebar theming

* fix: fixed env issue

* fix: fixed message not updating issue

* refactor: added isConnected prop in msgContainer

* refactor: resolve merge conflicts

* fix: fixed request sending

* fix: fixed decryption

* fix: fixed env issue

* feat: added profile header in message container

* feat: adding rainbowkit for btn

* fix: fix issues

* fix: addec onnect functionality

* fix: connect button

* fix: added hack for rainbowkit css

---------

Co-authored-by: KlausMikhaelson <satyamsingh5076@gmail.com>
Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>

* Typebar UI issue (#666)

* fix: fixed typebar space not working and theme

* fix: fixed gif and emoji

---------

Co-authored-by: KlausMikhaelson <satyamsingh5076@gmail.com>

* fix: fixed theme colours

* fix: added theme for brb

* fix: fixed access control hook issue

* feat: added access control verification

* feat: added onclick props for integration team to pass function and fixed btn ui

* fix: added link for learn more

* fix: fixed msg not updating in socket issue

* fix: added filter  hat

* fix: merged with main

* fix: fixed msg border

* fix: fixed theme

* fix: fixed fonts

* fix: fixed bug

* Access control (#672)

* fix: fixed typebar space not working and theme

* feat: created access control UI

* feat: created verify access control hook

* fix: fixed access control hook issue

* feat: added access control verification

* feat: added onclick props for integration team to pass function and fixed btn ui

* fix: added link for learn more

* fix: fixed msg not updating in socket issue

* fix: added minor fix

---------

Co-authored-by: Monalisha Mishra <mishramonalisha76@gmail.com>

* fix: fixed padding issues

* fix(f): fixed build issues

* fix: fix for chat status test

* feat: added verification option to show only on token gated groups

* fix: fixing group access control

* Check rules access control (#678)

* fix: fixed typebar space not working and theme

* feat: created access control UI

* feat: created verify access control hook

* fix: fixed access control hook issue

* feat: added access control verification

* feat: added onclick props for integration team to pass function and fixed btn ui

* fix: added link for learn more

* fix: fixed msg not updating in socket issue

* 662 group access control v2 changes (#663)

* fix: spaces access API

* fix: custom endpoint doc impl

* Update README.md

* Update README.md

* fix: review comments change

* fix: read me update

* Update README.md

* Update README.md

* fix: origin in user creation (#665)

* fix: origin in user creation

* Update README.md

* fix: review comments

* 662 group access control v2 changes (#677)

* fix: spaces access API

* fix: custom endpoint doc impl

* Update README.md

* Update README.md

* fix: review comments change

* fix: read me update

* Update README.md

* Update README.md

* fix(spaces): broadcast changes and UX fixes (#674)

* fix: fix UI grid view (#642)

* fix: fix UI grid view

* refactor: conditional added

* fix: resolved muting/unmuting try catch error (#657)

* fix(spaces): fix livepeer broadcast (#656)

* fix(spaces): fix livepeer broadcast

* fix(spaces): fix data shown for unjoined space & promote listener logic

---------

Co-authored-by: Madhur Gupta <madhur@push.org>

* refactor(spaces): use local state instead of get from server while meta message fire (#676)

---------

Co-authored-by: Arnab Chatterjee <60937304+arn4b@users.noreply.github.com>
Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>

* feat: added verification option to show only on token gated groups

* fix: fixing group access control

---------

Co-authored-by: Monalisha Mishra <mishramonalisha76@gmail.com>
Co-authored-by: Mohammed S <shoaib@push.org>
Co-authored-by: Madhur Gupta <madhur@push.org>
Co-authored-by: Arnab Chatterjee <60937304+arn4b@users.noreply.github.com>
Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>

* fix: fixed build

* feat: added send request to join group

* fix: fixed verification on send

* fix: fixed verify access btn not showing after joining group

* fix: fixed join group showing for members too

* fix: fixed join group showing to members

* 667 chat.send enhancement (#673)

* fix: changes messageObj for meta and reaction message type

* fix: enhance send fn

* fix: fixed intent issues

* 680 group rules cosmetic changes (#682)

* fix: fixed guild condition

* fix: add did validation

* fix: fixed

* fix: fixed minor issues

* fix: fixe dissue

* fix: fixed minor issues

* fix: check for scroll

* fix: fixed scrolling

* fix: fixed theme

* fix: fixed

* fix: fixed

* fix: fixed

* fix: fixed issues

* fix: fixed

* feat: added toast in join group btn for pvt groups

* fix: fixed blurr

---------

Co-authored-by: Monalisha Mishra <mishramonalisha76@gmail.com>
Co-authored-by: Monalisha Mishra <42746736+mishramonalisha76@users.noreply.github.com>
Co-authored-by: Kolade <corlardey@gmail.com>
Co-authored-by: Nilesh Gupta <guptanilesh2312@gmail.com>
Co-authored-by: Mohammed S <shoaib@push.org>
Co-authored-by: Madhur Gupta <madhur@push.org>
Co-authored-by: Arnab Chatterjee <60937304+arn4b@users.noreply.github.com>
Co-authored-by: Aman Gupta <guptaaman200115@gmail.com>
  • Loading branch information
9 people authored Aug 25, 2023
1 parent e1fc403 commit 2e178db
Show file tree
Hide file tree
Showing 43 changed files with 1,591 additions and 772 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const CreateGroupTest = () => {
env,
meta: meta,
rules: {
'chatAccess': {
'chat': {
'conditions': [
{
'all': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ChatViewComponentTest = () => {
{/* <Loader show={isLoading} /> */}
<ChatViewComponentCard>

<ChatViewComponent onClick={() => console.log("BOIIII RETURNNNSSSSS")} chatId='c4828a375fd261577927a9d73fe3fa30204c6667a3adbc345e010eccf5ec740e' limit={10}/>
<ChatViewComponent onClick={() => console.log("BOIIII RETURNNNSSSSS")} chatId='c2d544ad9d1efd5c5a593b143bf8232875c926cf28015564e70ad078b95f807e' limit={10}/>
</ChatViewComponentCard>
</div>
);
Expand All @@ -28,3 +28,4 @@ export default ChatViewComponentTest;
const ChatViewComponentCard = styled(Section)`
height: 60vh;
`;
//c2d544ad9d1efd5c5a593b143bf8232875c926cf28015564e70ad078b95f807e
2 changes: 1 addition & 1 deletion packages/examples/sdk-frontend-react/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export function App() {
<Web3Context.Provider value={{ account, active, library, chainId }}>
<SocketContext.Provider value={socketData}>
<AccountContext.Provider value={{ pgpPrivateKey, setSpaceId }}>
<ChatUIProvider account={account!} pgpPrivateKey={pgpPrivateKey} env={env} theme={darkChatTheme}>
<ChatUIProvider env={env} theme={lightChatTheme}>
<SpacesUIProvider spaceUI={spaceUI} theme={customDarkTheme}>
<Routes>
<Route
Expand Down
104 changes: 79 additions & 25 deletions packages/restapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3318,16 +3318,18 @@ const response = await PushAPI.chat.createGroup({
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'roleId': '19924'
'guildRoleId': '19924'
}
}
]
}
]
},
'chatAccess': {
'chat': {
'conditions': [
{
'all': [
Expand All @@ -3343,9 +3345,11 @@ const response = await PushAPI.chat.createGroup({
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'roleId': '19924'
'guildRoleId': '19924'
}
}
]
Expand Down Expand Up @@ -3413,15 +3417,15 @@ export interface Rules {
groupAccess?: {
conditions: Array<Condition | ConditionBase>
}
chatAccess?: {
chat?: {
conditions: Array<Condition | ConditionBase>
}
}
```

## Rules Object Description

The rules object consists of two main sections: `groupAccess` and `chatAccess`, both of which contain conditions to manage access and permissions within a chat application. These conditions may involve different criteria related to token holdings or guild membership.
The rules object consists of two main sections: `groupAccess` and `chat`, both of which contain conditions to manage access and permissions within a chat application. These conditions may involve different criteria related to token holdings or guild membership.

### Conditions

Expand Down Expand Up @@ -3458,15 +3462,37 @@ Explanation:

#### GUILD Conditions

GUILD conditions require both guildID and guildRoleId or guildRoleAction.
Sample GUILD condition schema
<pre>
{
"type": "GUILD",
"category": "guildRoles",
"subcategory": <Role Type>,
"data": {
"guildId": <Guild ID>,
"guildRoleId": <Specific Role ID>
}
}
</pre>

- **Working**:
Guild ID Validation: The function first checks for the presence of the guildId.
API Call: On confirming its presence, the function then fetches guild data from a specific API endpoint to ascertain the guild's validity.
Role and Action Checks: After validating the guild:
The function checks for the presence of guildRoleId or guildRoleAction. At least one must be specified.
If guildRoleId is given, its legitimacy is cross-verified with the guild's roles.
For guildRoleAction, the function ensures its value is strictly "all" or "any".

Fields:
type:
Always set to: "GUILD"
category:
Always set to: "guildRoles"
subcategory:
Role type classification.
Values:
specificRole: For a singular role.
allRoles: Pertaining to all roles in the guild.
anyRole: Referring to any role within the guild.
data:
guildId: Unique identifier of a guild.
guildRoleId: Role ID within the guild. (Required only for the specificRole subcategory.)
Usage:
This structure governs user permissions within a guild. The subcategory dictates the manner of role-based operations, from checking permissions of a single role (specificRole) to broad checks across any or all roles (anyRole, allRoles).

<details>
<summary><b>Expected response (create group)</b></summary>
Expand Down Expand Up @@ -3594,6 +3620,8 @@ For guildRoleAction, the function ensures its value is strictly "all" or "any".
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand All @@ -3611,7 +3639,7 @@ For guildRoleAction, the function ensures its value is strictly "all" or "any".
}
]
},
'chatAccess': {
'chat': {
'conditions': [
{
'all': [
Expand All @@ -3627,16 +3655,19 @@ For guildRoleAction, the function ensures its value is strictly "all" or "any".
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
}
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'anyRole',
'data': {
'guildId': '13468',
'guildRoleAction': 'all/any'
'guildId': '13468'
}
}
]
Expand Down Expand Up @@ -3680,7 +3711,7 @@ Allowed Options (params with _ are mandatory)
// PushAPI_chat_getGroupAccess | Response - 200 OK
{
'groupAccess': true,
'chatAccess': false,
'chat': false,
'rules': {
'groupAccess': {
'conditions': [
Expand All @@ -3699,6 +3730,8 @@ Allowed Options (params with _ are mandatory)
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand All @@ -3719,7 +3752,7 @@ Allowed Options (params with _ are mandatory)
}
]
},
'chatAccess': {
'chat': {
'conditions': [
{
'all': [
Expand All @@ -3736,6 +3769,8 @@ Allowed Options (params with _ are mandatory)
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand Down Expand Up @@ -3817,6 +3852,8 @@ const response = await PushAPI.chat.updateGroup({
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guidlRoleId': '19924'
Expand All @@ -3826,7 +3863,7 @@ const response = await PushAPI.chat.updateGroup({
}
]
},
'chatAccess': {
'chat': {
'conditions': [
{
'all': [
Expand All @@ -3842,6 +3879,8 @@ const response = await PushAPI.chat.updateGroup({
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand Down Expand Up @@ -4017,6 +4056,8 @@ Allowed Options (params with _ are mandatory)
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand All @@ -4026,7 +4067,7 @@ Allowed Options (params with _ are mandatory)
}
]
},
'chatAccess': {
'chat': {
'conditions': [
{
'all': [
Expand All @@ -4042,6 +4083,8 @@ Allowed Options (params with _ are mandatory)
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand Down Expand Up @@ -4716,6 +4759,8 @@ const response = await PushAPI.space.create({
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand Down Expand Up @@ -4791,7 +4836,7 @@ export interface Rules {
groupAccess?: {
conditions: Array<Condition | ConditionBase>
}
chatAccess?: {
chat?: {
conditions: Array<Condition | ConditionBase>
}
}
Expand Down Expand Up @@ -4893,6 +4938,8 @@ export interface Rules {
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand Down Expand Up @@ -4957,6 +5004,8 @@ Allowed Options (params with _ are mandatory)
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'guildRoleId': '19924'
Expand Down Expand Up @@ -5053,16 +5102,17 @@ const response = await PushAPI.space.update({
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'allRoles',
'data': {
'guildId': '13468',
'roleId': '19924'
'guildId': '13468'
}
}
]
}
]
},
'chatAccess': {
'chat': {
'conditions': [
{
'all': [
Expand All @@ -5078,9 +5128,11 @@ const response = await PushAPI.space.update({
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'roleId': '19924'
'guildRoleId': '19924'
}
}
]
Expand Down Expand Up @@ -5221,9 +5273,11 @@ Allowed Options (params with _ are mandatory)
},
{
'type': 'GUILD',
'category': 'guildRoles',
'subcategory': 'specificRole',
'data': {
'guildId': '13468',
'roleId': '19924'
'guildRoleId': '19924'
}
},
{
Expand Down
6 changes: 5 additions & 1 deletion packages/restapi/src/lib/chat/getGroupAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import axios from 'axios';
import { getAPIBaseUrls } from '../helpers';
import Constants, { ENV } from '../constants';
import { GroupAccess } from '../types';
import { getUserDID } from './helpers';

/**
* GET /v1/chat/groups/:chatId/access/:did
Expand All @@ -22,12 +23,15 @@ export const getGroupAccess = async (
if (chatId == null || chatId.length === 0) {
throw new Error(`chatId cannot be null or empty`);
}

if (did == null || did.length === 0) {
throw new Error(`did cannot be null or empty`);
}

const user = await getUserDID(did, env);

const API_BASE_URL = getAPIBaseUrls(env);
const requestUrl = `${API_BASE_URL}/v1/chat/groups/${chatId}/access/${did}`;
const requestUrl = `${API_BASE_URL}/v1/chat/groups/${chatId}/access/${user}`;
return axios
.get(requestUrl)
.then((response) => {
Expand Down
Loading

0 comments on commit 2e178db

Please sign in to comment.