Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/dappforce/grillchat into de…
Browse files Browse the repository at this point in the history
…ploy/iframe-fix
  • Loading branch information
teodorus-nathaniel committed Aug 28, 2023
2 parents 4cf5408 + 7436713 commit 4d67a49
Show file tree
Hide file tree
Showing 21 changed files with 236 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ SERVER_MNEMONIC=<your mnemonic here to send energy to users>
SERVER_DISCUSSION_CREATOR_MNEMONIC=<discussions creator user mnemonic>

CRUST_IPFS_AUTH=<IPFS auth for using crust bucket>
IPFS_WRITE_URL=<IPFS write url>
IPFS_PIN_URL=<IPFS pinning service url>
# ipfs test values
# CRUST_IPFS_AUTH=eyJkYXRhIjp7ImRvbWFpbiI6eyJjaGFpbklkIjoiNSIsIm5hbWUiOiJDbG91ZDMuY2MiLCJ2ZXJpZnlpbmdDb250cmFjdCI6IjB4Q2NDQ2NjY2NDQ0NDY0NDQ0NDQ2NDY0NjY0NjQ0NDY0NjY2NjY2NjQyIsInZlcnNpb24iOiIxIn0sIm1lc3NhZ2UiOnsiZGVzY3JpcHRpb24iOiJTaWduIGZvciBXMyBCdWNrZXQgQWNjZXNzIEF1dGhlbnRpY2F0aW9uIiwic2lnbmluZ0FkZHJlc3MiOiIweDAwNDFjNzA1ZTEwNmVlOWRFMjI3Q2ExMzlBZDRBOTlEQjY0NENCM2EiLCJ0b2tlbkFkZHJlc3MiOiIweDM5ODY2Mzg0MjY4MDMzMkExQWJBM0IwM2JkNmRCNDdhRTk4NDk5NEMiLCJ0b2tlbklkIjoiMzAwMDAzNyIsImVmZmVjdGl2ZVRpbWVzdGFtcCI6MTY3ODUzNzYxNywiZXhwaXJhdGlvblRpbWVzdGFtcCI6MH0sInByaW1hcnlUeXBlIjoiVzNCdWNrZXQiLCJ0eXBlcyI6eyJXM0J1Y2tldCI6W3sibmFtZSI6ImRlc2NyaXB0aW9uIiwidHlwZSI6InN0cmluZyJ9LHsibmFtZSI6InNpZ25pbmdBZGRyZXNzIiwidHlwZSI6ImFkZHJlc3MifSx7Im5hbWUiOiJ0b2tlbkFkZHJlc3MiLCJ0eXBlIjoiYWRkcmVzcyJ9LHsibmFtZSI6InRva2VuSWQiLCJ0eXBlIjoic3RyaW5nIn0seyJuYW1lIjoiZWZmZWN0aXZlVGltZXN0YW1wIiwidHlwZSI6InVpbnQyNTYifSx7Im5hbWUiOiJleHBpcmF0aW9uVGltZXN0YW1wIiwidHlwZSI6InVpbnQyNTYifV19fSwic2lnbmF0dXJlIjoiMHhhMTUxODkyZGNhMTZlMTJkZmViYTFjY2FkMjNmZjM5MGVmODQ1MzdhMGI2MWI4YWQ1NDY1ZGI1ZjI1NjZkMWJmMjc3MGE1OTQyMzFmNzFmYzA5YWVlZGJhNzJkZjM5Y2Y4NDIxMTQ3YzJkNWQyNTFkNDZjNGQyMDFlOGM1MmUzZTFjIn0=
# IPFS_WRITE_URL=https://gw-seattle.crustcloud.io
# IPFS_PIN_URL=https://test-pin.crustcloud.io/psa

NEXT_PUBLIC_SPACE_IDS=<your space(s) where all the posts here will be listed as topics, you can support multiple space ids, separated by comma>
Expand Down
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SERVER_MNEMONIC="bounce clutch hotel number lab imitate grass loop jewel cousin

# ipfs test values
CRUST_IPFS_AUTH="eyJkYXRhIjp7ImRvbWFpbiI6eyJjaGFpbklkIjoiNSIsIm5hbWUiOiJDbG91ZDMuY2MiLCJ2ZXJpZnlpbmdDb250cmFjdCI6IjB4Q2NDQ2NjY2NDQ0NDY0NDQ0NDQ2NDY0NjY0NjQ0NDY0NjY2NjY2NjQyIsInZlcnNpb24iOiIxIn0sIm1lc3NhZ2UiOnsiZGVzY3JpcHRpb24iOiJTaWduIGZvciBXMyBCdWNrZXQgQWNjZXNzIEF1dGhlbnRpY2F0aW9uIiwic2lnbmluZ0FkZHJlc3MiOiIweDAwNDFjNzA1ZTEwNmVlOWRFMjI3Q2ExMzlBZDRBOTlEQjY0NENCM2EiLCJ0b2tlbkFkZHJlc3MiOiIweDM5ODY2Mzg0MjY4MDMzMkExQWJBM0IwM2JkNmRCNDdhRTk4NDk5NEMiLCJ0b2tlbklkIjoiMzAwMDAzNyIsImVmZmVjdGl2ZVRpbWVzdGFtcCI6MTY3ODUzNzYxNywiZXhwaXJhdGlvblRpbWVzdGFtcCI6MH0sInByaW1hcnlUeXBlIjoiVzNCdWNrZXQiLCJ0eXBlcyI6eyJXM0J1Y2tldCI6W3sibmFtZSI6ImRlc2NyaXB0aW9uIiwidHlwZSI6InN0cmluZyJ9LHsibmFtZSI6InNpZ25pbmdBZGRyZXNzIiwidHlwZSI6ImFkZHJlc3MifSx7Im5hbWUiOiJ0b2tlbkFkZHJlc3MiLCJ0eXBlIjoiYWRkcmVzcyJ9LHsibmFtZSI6InRva2VuSWQiLCJ0eXBlIjoic3RyaW5nIn0seyJuYW1lIjoiZWZmZWN0aXZlVGltZXN0YW1wIiwidHlwZSI6InVpbnQyNTYifSx7Im5hbWUiOiJleHBpcmF0aW9uVGltZXN0YW1wIiwidHlwZSI6InVpbnQyNTYifV19fSwic2lnbmF0dXJlIjoiMHhhMTUxODkyZGNhMTZlMTJkZmViYTFjY2FkMjNmZjM5MGVmODQ1MzdhMGI2MWI4YWQ1NDY1ZGI1ZjI1NjZkMWJmMjc3MGE1OTQyMzFmNzFmYzA5YWVlZGJhNzJkZjM5Y2Y4NDIxMTQ3YzJkNWQyNTFkNDZjNGQyMDFlOGM1MmUzZTFjIn0="
IPFS_WRITE_URL=https://gw-seattle.crustcloud.io
IPFS_PIN_URL="https://test-pin.crustcloud.io/psa"

NEXT_PUBLIC_SPACE_IDS="1001"
Expand Down
51 changes: 51 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: 🐛 Bug Report
about: Template for reporting bugs
title: '<title>'
labels: bug
assignees: ''
---

<!--
Note: Please search to see if an issue already exists for the bug you encountered.
-->

### Current Behavior:

<!-- A concise description of what you're experiencing. -->

### Expected Behavior:

<!-- A concise description of what you expected to happen. -->

### Steps To Reproduce:

<!--
Example: steps to reproduce the behavior:
1. In this environment...
1. With this config...
1. Run '...'
1. See error...
-->

## Environment

<!-- What is the environment that the bug happens?
Example:
- OS: Ubuntu 20.04
- Node: 13.14.0
- npm: 7.6.3
-->

## ✔️ Possible solutions

<!-- (This section is optional.)
Any hint on how to solve the issue?
What parts of the code will be affected?
-->

### Anything else:

<!--
Links? References? Anything that will give us more context about the issue that you are encountering!
-->
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: ✨ Feature request
about: Template for requesting new features
title: '<title>'
labels: enhancement
assignees: ''
---

## 📚 Context

<!--
What is the problem that you are trying to solve?
Why is this problem relevant?
-->

## ✔️ Solution

<!--
(This section and the ones below are optional.)
What are the possible solutions?
If there are multiple, what are the benefits and drawbacks of each one?
-->

## 📈 Subtasks

<!--
- [ ] If there is a solution, what are the subtasks for completing this issue?
-->

## 🎯 Definition of Done

<!--
- [ ] If there is a solution, what are the final deliverables?
-->
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
reviewers:
- 'oap75'
- 'olehmell'
schedule:
interval: 'weekly'
commit-message:
prefix: 'dependabot'
pull-request-branch-name:
separator: '/'
8 changes: 5 additions & 3 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Build production image
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
Expand All @@ -61,7 +61,8 @@ jobs:
GH_NEXT_PUBLIC_SQUID_URL=https://squid.subsquid.io/xsocial/graphql
GH_NEXT_PUBLIC_COMMUNITY_HUB_ID=1030
GH_NEXT_PUBLIC_GA_ID=G-FT28TL1W3M
GH_IPFS_PIN_URL=https://pin.crustcloud.io/psa
GH_IPFS_WRITE_URL=http://new-ipfs-cluster:5001
GH_IPFS_PIN_URL=http://new-ipfs-cluster:9094
GH_CRUST_IPFS_AUTH=${{ secrets.CRUST_IPFS_AUTH }}
GH_SUBSOCIAL_PROMO_SECRET_HEX=${{ secrets.SUBSOCIAL_PROMO_SECRET_HEX }}
GH_USER_ID_SALT=${{ secrets.USER_ID_SALT }}
Expand All @@ -86,7 +87,7 @@ jobs:

- name: Build storybook image
if: ${{ github.ref == 'refs/heads/storybook' }}
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
Expand All @@ -100,6 +101,7 @@ jobs:
GH_NEXT_PUBLIC_AMP_ID=81d0fc2014ce14eed5a475efe9a44035
GH_NEXT_PUBLIC_SQUID_URL=https://squid.subsquid.io/xsocial/graphql
GH_NEXT_PUBLIC_GA_ID=G-FT28TL1W3M
GH_IPFS_WRITE_URL=https://gw-seattle.crustcloud.io
GH_IPFS_PIN_URL=https://pin.crustcloud.io/psa
GH_CRUST_IPFS_AUTH=${{ secrets.CRUST_IPFS_AUTH }}
GH_SUBSOCIAL_PROMO_SECRET_HEX=${{ secrets.SUBSOCIAL_PROMO_SECRET_HEX }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/feature-based-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout main
uses: actions/checkout@v3

- uses: mdecoleman/pr-branch-name@1.2.0
- uses: mdecoleman/pr-branch-name@2.0.0
id: vars
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/feature-based.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
${{ runner.os }}-single-buildx
- name: Build docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
Expand All @@ -67,6 +67,7 @@ jobs:
GH_NEXT_PUBLIC_SQUID_URL=https://squid.subsquid.io/xsocial/graphql
GH_NEXT_PUBLIC_COMMUNITY_HUB_ID=1025
GH_NEXT_PUBLIC_GA_ID=G-FT28TL1W3M
GH_IPFS_WRITE_URL=https://gw-seattle.crustcloud.io
GH_IPFS_PIN_URL=https://test-pin.crustcloud.io/psa
GH_COVALENT_API_KEY=cqt_rQtDdp9G9DFvqcGjVPDD4FFCyhFQ
GH_NEXT_PUBLIC_NOTIFICATION_APP_ID=BJaKjx7xtiIXtSUT8tR6VDG0WwhFwdqOqp8L5kc6alGBUtndnlV_DUJ6sze_z70VEBOKk4AT_wZTJqE9dC7sbEQ
Expand Down
1 change: 1 addition & 0 deletions ci.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NEXT_PUBLIC_AMP_ID='$GH_NEXT_PUBLIC_AMP_ID'
NEXT_PUBLIC_SQUID_URL='$GH_NEXT_PUBLIC_SQUID_URL'
NEXT_PUBLIC_COMMUNITY_HUB_ID='$GH_NEXT_PUBLIC_COMMUNITY_HUB_ID'
NEXT_PUBLIC_GA_ID='$GH_NEXT_PUBLIC_GA_ID'
IPFS_WRITE_URL='$GH_IPFS_WRITE_URL'
IPFS_PIN_URL='$GH_IPFS_PIN_URL'
CRUST_IPFS_AUTH='GH_CRUST_IPFS_AUTH'
USER_ID_SALT='$GH_USER_ID_SALT'
Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ARG GH_NEXT_PUBLIC_AMP_ID
ARG GH_NEXT_PUBLIC_SQUID_URL
ARG GH_NEXT_PUBLIC_COMMUNITY_HUB_ID
ARG GH_NEXT_PUBLIC_GA_ID
ARG GH_IPFS_WRITE_URL
ARG GH_IPFS_PIN_URL
ARG GH_COVALENT_API_KEY
ARG GH_SUBSOCIAL_PROMO_SECRET_HEX
Expand All @@ -45,6 +46,7 @@ ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY=${GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY} \
NEXT_PUBLIC_SQUID_URL=${GH_NEXT_PUBLIC_SQUID_URL} \
NEXT_PUBLIC_COMMUNITY_HUB_ID=${GH_NEXT_PUBLIC_COMMUNITY_HUB_ID} \
NEXT_PUBLIC_GA_ID=${GH_NEXT_PUBLIC_GA_ID} \
IPFS_WRITE_URL=${GH_IPFS_WRITE_URL} \
IPFS_PIN_URL=${GH_IPFS_PIN_URL} \
CAPTCHA_SECRET=${GH_CAPTCHA_SECRET} \
USER_ID_SALT=${GH_USER_ID_SALT} \
Expand Down Expand Up @@ -90,6 +92,7 @@ ARG GH_NEXT_PUBLIC_AMP_ID
ARG GH_NEXT_PUBLIC_SQUID_URL
ARG GH_NEXT_PUBLIC_COMMUNITY_HUB_ID
ARG GH_NEXT_PUBLIC_GA_ID
ARG GH_IPFS_WRITE_URL
ARG GH_IPFS_PIN_URL
ARG GH_COVALENT_API_KEY
ARG GH_SUBSOCIAL_PROMO_SECRET_HEX
Expand All @@ -112,6 +115,7 @@ ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY=${GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY} \
NEXT_PUBLIC_SQUID_URL=${GH_NEXT_PUBLIC_SQUID_URL} \
NEXT_PUBLIC_COMMUNITY_HUB_ID=${GH_NEXT_PUBLIC_COMMUNITY_HUB_ID} \
NEXT_PUBLIC_GA_ID=${GH_NEXT_PUBLIC_GA_ID} \
IPFS_WRITE_URL=${GH_IPFS_WRITE_URL} \
IPFS_PIN_URL=${GH_IPFS_PIN_URL} \
CAPTCHA_SECRET=${GH_CAPTCHA_SECRET} \
USER_ID_SALT=${GH_USER_ID_SALT} \
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"@polkadot/keyring": "^12.1.2",
"@polkadot/util": "^12.1.2",
"@rainbow-me/rainbowkit": "^1.0.4",
"@subsocial/api": "^0.8.12",
"@subsocial/api": "^0.8.14",
"@subsocial/grill-widget": "^0.0.8",
"@subsocial/utils": "0.8.13",
"@subsocial/utils": "0.8.14",
"@subwallet/wagmi-connector": "^0.1.1",
"@talismn/wagmi-connector": "^0.3.1",
"@tanstack/react-query": "^4.24.10",
Expand Down
4 changes: 4 additions & 0 deletions src/components/AddressAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import useRandomColor from '@/hooks/useRandomColor'
import { getProfileQuery } from '@/services/mainnet-squid/query'
import { getAccountDataQuery } from '@/services/subsocial/evmAddresses'
import { cx } from '@/utils/class-names'
import { getIpfsContentUrl } from '@/utils/ipfs'
import * as bottts from '@dicebear/bottts'
import { createAvatar } from '@dicebear/core'
import Image from 'next/image'
Expand Down Expand Up @@ -65,6 +66,9 @@ const AddressAvatar = forwardRef<HTMLDivElement, AddressAvatarProps>(
}

let usedAvatar = profile?.profileSpace?.image
? getIpfsContentUrl(profile?.profileSpace?.image)
: undefined

if (ensName) {
usedAvatar = resolveEnsAvatarSrc(ensName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function DisableNotificationButton({
// FCM Token Disabled.
fcmPushNotificationStorage.remove()
setIsRegistered(false)
sendEvent('wp_notifs_disabled', undefined, { wpNotifsEnabled: false })
sendEvent('wp_notifs_disabled', undefined, { webNotifsEnabled: false })
},
})

Expand Down Expand Up @@ -119,7 +119,7 @@ function EnableNotificationButton({
if (fcmToken) {
fcmPushNotificationStorage.set(fcmToken)
setIsRegistered(true)
sendEvent('wp_notifs_allowed', undefined, { wpNotifsEnabled: true })
sendEvent('wp_notifs_allowed', undefined, { webNotifsEnabled: true })
}
},
})
Expand Down
16 changes: 9 additions & 7 deletions src/components/chats/ChatItem/LinkPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ export default function LinkPreview({
>
{truncatedDesc}
</p>
<MediaLoader
src={linkMetadata.image ?? ''}
alt=''
width={600}
height={400}
className='mt-2 max-h-72 rounded-lg bg-background-lighter/50 object-contain'
/>
{linkMetadata.image && (
<MediaLoader
src={linkMetadata.image ?? ''}
alt=''
width={600}
height={400}
className='mt-2 max-h-72 rounded-lg bg-background-lighter/50 object-contain'
/>
)}
{internalLinkText && (
<Button
onClick={(e) => e.stopPropagation()}
Expand Down
1 change: 1 addition & 0 deletions src/components/chats/ChatPreviewList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function ChatPreviewContainer({
const onChatClick = () => {
sendEvent(`open_chat`, {
chatId: chat.id,
hubId,
})

if (chat.id === ANN_CHAT_ID) {
Expand Down
36 changes: 23 additions & 13 deletions src/server/ipfs.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { getCrustIpfsAuth, getIpfsPinUrl } from '@/utils/env/server'
import {
getCrustIpfsAuth,
getIpfsPinUrl,
getIpfsWriteUrl,
} from '@/utils/env/server'
import { SubsocialIpfsApi } from '@subsocial/api'

export function getIpfsApi() {
const CRUST_IPFS_CONFIG = {
ipfsNodeUrl: 'https://gw-seattle.crustcloud.io',
ipfsClusterUrl: getIpfsPinUrl(),
}
const pinUrl = getIpfsPinUrl()
const writeUrl = getIpfsWriteUrl()

console.log('pinUrl', pinUrl)
console.log('writeUrl', writeUrl)

const props = pinUrl.includes('crust')
? { asLink: false, 'meta.gatewayId': 1 }
: { asLink: true }

const headers = { authorization: `Bearer ${getCrustIpfsAuth()}` }

const ipfs = new SubsocialIpfsApi({
...CRUST_IPFS_CONFIG,
ipfsNodeUrl: writeUrl,
ipfsClusterUrl: pinUrl,
headers,
offchainUrl: 'https://api.subsocial.network',
})
Expand All @@ -19,15 +30,14 @@ export function getIpfsApi() {
return {
ipfs,
saveAndPinJson: async (content: Record<any, any>) => {
const cid = await ipfs.saveContentToOffchain(content as any)
// const cid = await ipfs.saveJson(content)
// await ipfs.pinContent(cid, { 'meta.gatewayId': 1 })
// const cid = await ipfs.saveContentToOffchain(content as any)
const cid = await ipfs.saveJson(content)
await ipfs.pinContent(cid, props)
return cid?.toString() ?? ''
},
saveAndPinImage: async (content: any) => {
// const cid = await ipfs.saveFileToOffchain(content as any)!
const cid = await ipfs.saveFile(content)
await ipfs.pinContent(cid, { 'meta.gatewayId': 1 })
saveAndPinImage: async (file: any) => {
const cid = await ipfs.saveFile(file)
await ipfs.pinContent(cid, props)
return cid?.toString() ?? ''
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/stores/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type UserProperties = {
pwaInstalled?: boolean
evmLinked?: boolean
tgNotifsConnected?: boolean
wpNotifsEnabled?: boolean
webNotifsEnabled?: boolean
ownedChat?: boolean
hasJoinedChats?: boolean
}
Expand Down
Loading

0 comments on commit 4d67a49

Please sign in to comment.