Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ebradbury/community-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ebradbury committed Jan 16, 2025
2 parents c1808e0 + 18a4001 commit 9423027
Show file tree
Hide file tree
Showing 257 changed files with 3,366 additions and 3,473 deletions.
18 changes: 18 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,24 @@
"contributions": [
"code"
]
},
{
"login": "detrina",
"name": "Devkuni",
"avatar_url": "https://avatars.githubusercontent.com/u/155117116?v=4",
"profile": "https://github.com/detrina",
"contributions": [
"doc"
]
},
{
"login": "Bilogweb3",
"name": "Bilog WEB3",
"avatar_url": "https://avatars.githubusercontent.com/u/155262265?v=4",
"profile": "https://github.com/Bilogweb3",
"contributions": [
"doc"
]
}
],
"projectName": "community-platform",
Expand Down
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ jobs:
--build-secret VITE_DONATIONS_IMAGE_URL="$VITE_DONATIONS_IMAGE_URL" \
--build-secret VITE_HOWTOS_HEADING="$VITE_HOWTOS_HEADING" \
--build-secret VITE_COMMUNITY_PROGRAM_URL="$VITE_COMMUNITY_PROGRAM_URL" \
--build-secret VITE_QUESTIONS_GUIDELINES_URL="$VITE_QUESTIONS_GUIDELINES_URL"
--build-secret VITE_QUESTIONS_GUIDELINES_URL="$VITE_QUESTIONS_GUIDELINES_URL" \
--build-secret VITE_HIDE_MEMBER_PINS_BY_DEFAULT="$VITE_HIDE_MEMBER_PINS_BY_DEFAULT"
- run:
name: Set Supabase Secrets
command: flyctl -a << parameters.FLY_APP_NAME >> secrets set SUPABASE_API_URL=$SUPABASE_API_URL SUPABASE_KEY=$SUPABASE_KEY FIREBASE_PROJECT_ID=$FIREBASE_PROJECT_ID FIREBASE_PRIVATE_KEY="$FIREBASE_PRIVATE_KEY" FIREBASE_CLIENT_EMAIL=$FIREBASE_CLIENT_EMAIL
Expand Down
7 changes: 5 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ VITE_THEME=precious-plastic

# Academies that exist https://onearmy.github.io/academy/, https://project-kamp-academy.netlify.app/, https://fixing-fashion-academy.netlify.app/
VITE_ACADEMY_RESOURCE=https://onearmy.github.io/academy/
VITE_DONATIONS_BODY=All of the content here is free. Your donation supports this library of Open Source recycling knowledge. Making it possible for everyone in the world to use it and start recycling.
VITE_DONATIONS_BODY=All of the content here is free. Your donation supports this library of open source recycling knowledge. Making it possible for everyone in the world to use it and start recycling.
VITE_DONATIONS_IFRAME_SRC=https://donorbox.org/embed/ppcpdonor?language=en
VITE_DONATIONS_IMAGE_URL=/assets/img/precious-plastic/donation-banner.jpg
VITE_HOWTOS_HEADING=Learn & share how to recycle, build and work with plastic
VITE_HOWTOS_HEADING=The largest open source library of plastic recycling tools
VITE_SITE_NAME=Precious Plastic

# Progamme urls are https://community.<domain>/academy/guides/community-program
Expand All @@ -20,6 +20,9 @@ VITE_COMMUNITY_PROGRAM_URL=https://community.preciousplastic.com/academy/guides/
VITE_PROFILE_GUIDELINES_URL=https://community.preciousplastic.com/academy/guides/platform
VITE_QUESTIONS_GUIDELINES_URL=https://community.preciousplastic.com/academy/guides/guidelines-questions

# Optional variable for limiting the display of member map pins by default on load
VITE_HIDE_MEMBER_PINS_BY_DEFAULT=false

# For testing, VITE_PLATFORM_PROFILES in localStorage is prioritised over this value
# All valid options for VITE_PLATFORM_PROFILES: "member,workspace,community-builder,space,collection-point,machine-builder"
VITE_PLATFORM_PROFILES="member,workspace,community-builder,collection-point,machine-builder"
Expand Down
4 changes: 2 additions & 2 deletions .github/pr-labeler.config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration for pr-labeller actions
"Mod: HowTo 📰":
- src/pages/Howto/**/*
"Mod: Library 📰":
- src/pages/Library/**/*
"Mod: Maps 🗺":
- src/pages/Maps/**/*
"Mod: Research 🔬":
Expand Down
2 changes: 1 addition & 1 deletion BOUNTIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _Note_ - the exact bounty level is not included as knowing in advance how much w

## How do I claim them?

### Step 1 - Assigned the issue
### Step 1 - Assign the issue

Drop a message in the issue thread to say that you are interested taking it on. If the issue is already assigned, or we think it might be too much for a new or individual contributor we might suggest looking at other issues instead. Otherwise it's all yours :D

Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ARG VITE_DONATIONS_IMAGE_URL
ARG VITE_HOWTOS_HEADING
ARG VITE_COMMUNITY_PROGRAM_URL
ARG VITE_QUESTIONS_GUIDELINES_URL
ARG VITE_HIDE_MEMBER_PINS_BY_DEFAULT

# Throw-away build stage to reduce size of final image
FROM base AS build
Expand Down Expand Up @@ -80,6 +81,7 @@ RUN --mount=type=secret,id=VITE_BRANCH \
--mount=type=secret,id=VITE_HOWTOS_HEADING \
--mount=type=secret,id=VITE_COMMUNITY_PROGRAM_URL \
--mount=type=secret,id=VITE_QUESTIONS_GUIDELINES_URL \
--mount=type=secret,id=VITE_HIDE_MEMBER_PINS_BY_DEFAULT \
VITE_CDN_URL="$(cat /run/secrets/VITE_CDN_URL)" && \
VITE_BRANCH="$(cat /run/secrets/VITE_BRANCH)" && \
VITE_FIREBASE_API_KEY="$(cat /run/secrets/VITE_FIREBASE_API_KEY)" && \
Expand All @@ -105,6 +107,7 @@ RUN --mount=type=secret,id=VITE_BRANCH \
VITE_HOWTOS_HEADING="$(cat /run/secrets/VITE_HOWTOS_HEADING)" && \
VITE_COMMUNITY_PROGRAM_URL="$(cat /run/secrets/VITE_COMMUNITY_PROGRAM_URL)" && \
VITE_QUESTIONS_GUIDELINES_URL="$(cat /run/secrets/VITE_QUESTIONS_GUIDELINES_URL)" && \
VITE_HIDE_MEMBER_PINS_BY_DEFAULT="$(cat /run/secrets/VITE_HIDE_MEMBER_PINS_BY_DEFAULT)" && \
echo "VITE_CDN_URL=\"${VITE_CDN_URL}\"" >> .env && \
echo "VITE_BRANCH=\"${VITE_BRANCH}\"" >> .env && \
echo "VITE_FIREBASE_API_KEY=\"${VITE_FIREBASE_API_KEY}\"" >> .env && \
Expand All @@ -129,7 +132,8 @@ RUN --mount=type=secret,id=VITE_BRANCH \
echo "VITE_DONATIONS_IMAGE_URL=\"${VITE_DONATIONS_IMAGE_URL}\"" >> .env && \
echo "VITE_HOWTOS_HEADING=\"${VITE_HOWTOS_HEADING}\"" >> .env && \
echo "VITE_COMMUNITY_PROGRAM_URL=\"${VITE_COMMUNITY_PROGRAM_URL}\"" >> .env && \
echo "VITE_QUESTIONS_GUIDELINES_URL=\"${VITE_QUESTIONS_GUIDELINES_URL}\"" >> .env
echo "VITE_QUESTIONS_GUIDELINES_URL=\"${VITE_QUESTIONS_GUIDELINES_URL}\"" >> .env && \
echo "VITE_HIDE_MEMBER_PINS_BY_DEFAULT=\"${VITE_HIDE_MEMBER_PINS_BY_DEFAULT}\"" >> .env

# Build application
RUN yarn run build
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This platform aims to tackle these problems by creating a strong unified communi

## ⚡️ &nbsp; What is this platform?

Our community platform helps people to grow communities and make it easier to collaborate on environmental projects in one single place. A place where people can meet, help each other, ask and answer questions, share their innovative ways of fixing problems, discover people around them, connect locally and more. It aims to provide the tools to connect both online and offline. Amongst other features we have How-to and Maps.
Our community platform helps people to grow communities and make it easier to collaborate on environmental projects in one single place. A place where people can meet, help each other, ask and answer questions, share their innovative ways of fixing problems, discover people around them, connect locally and more. It aims to provide the tools to connect both online and offline. Amongst other features we have a library of projects, research, questions, commenting and a map.

### Have a look on our [website](https://platform.onearmy.earth) to have a clear overview

Expand Down Expand Up @@ -178,6 +178,8 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc
<td align="center" valign="top" width="14.28%"><a href="https://www.behance.net/dalibormrska"><img src="https://avatars.githubusercontent.com/u/35503298?v=4?s=60" width="60px;" alt="Dalibor Mrška"/><br /><sub><b>Dalibor Mrška</b></sub></a><br /><a href="#design-dalibormrska" title="Design">🎨</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sky-coderay"><img src="https://avatars.githubusercontent.com/u/137945430?v=4?s=60" width="60px;" alt="Skylar Ray"/><br /><sub><b>Skylar Ray</b></sub></a><br /><a href="https://github.com/ONEARMY/community-platform/commits?author=sky-coderay" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://johannesross.de"><img src="https://avatars.githubusercontent.com/u/74828657?v=4?s=60" width="60px;" alt="Johannes Roß"/><br /><sub><b>Johannes Roß</b></sub></a><br /><a href="https://github.com/ONEARMY/community-platform/commits?author=johannes-ross" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/detrina"><img src="https://avatars.githubusercontent.com/u/155117116?v=4?s=60" width="60px;" alt="Devkuni"/><br /><sub><b>Devkuni</b></sub></a><br /><a href="https://github.com/ONEARMY/community-platform/commits?author=detrina" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Bilogweb3"><img src="https://avatars.githubusercontent.com/u/155262265?v=4?s=60" width="60px;" alt="Bilog WEB3"/><br /><sub><b>Bilog WEB3</b></sub></a><br /><a href="https://github.com/ONEARMY/community-platform/commits?author=Bilogweb3" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docs/supabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ After making schema changes, use the this command to create a migration file:
Multi-tenancy is a requirement because:

- Single login for all websites.
- Easier maintenence and migrations.
- Easier maintenance and migrations.

With supabase there are a few ways we can do multi-tenancy:

Expand Down
8 changes: 4 additions & 4 deletions functions/src/Integrations/firebase-discord.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from 'axios'
import * as functions from 'firebase-functions'
import { IResearchDB, ResearchUpdateStatus } from 'oa-shared/models/research'
import { IModerationStatus } from 'oa-shared'
import { IResearchDB, ResearchUpdateStatus } from 'oa-shared/models/research'

import { CONFIG } from '../config/config'

import type { AxiosError, AxiosResponse } from 'axios'
import type { IResearch, IMapPin } from 'oa-shared/models'
import type { IMapPin, IResearch } from 'oa-shared/models'

const SITE_URL = CONFIG.deployment.site_url
// e.g. https://dev.onearmy.world or https://community.preciousplastic.com
Expand Down Expand Up @@ -51,8 +51,8 @@ export const notifyHowtoPublished = functions
const { _createdBy, title, slug } = info
await axios
.post(DISCORD_WEBHOOK_URL, {
content: `📓 Yeah! New How To **${title}** by *${_createdBy}*
check it out: <${SITE_URL}/how-to/${slug}>`,
content: `📓 Yeah! New library project **${title}** by *${_createdBy}*
check it out: <${SITE_URL}/library/${slug}>`,
})
.then(handleResponse, handleErr)
.catch(handleErr)
Expand Down
9 changes: 5 additions & 4 deletions functions/src/Integrations/firebase-slack.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { CONFIG } from '../config/config'
import * as functions from 'firebase-functions'
import axios from 'axios'
import * as functions from 'firebase-functions'
import { IModerationStatus } from 'oa-shared'

import { CONFIG } from '../config/config'

const SITE_URL = CONFIG.deployment.site_url
// e.g. https://dev.onearmy.world or https://community.preciousplastic.com

Expand Down Expand Up @@ -39,8 +40,8 @@ export const notifyHowtoAwaitingModeration = functions

return await axios
.post(SLACK_WEBHOOK_URL, {
text: `📓 Yeah! New How To *${title}* by _${user}_ awaiting moderation,
check it out: ${SITE_URL}/how-to/${slug}`,
text: `📓 Yeah! New library project *${title}* by _${user}_ awaiting moderation,
check it out: ${SITE_URL}/library/${slug}`,
})
.catch((err) => {
console.error(err)
Expand Down
10 changes: 5 additions & 5 deletions functions/src/emailNotifications/createModerationEmails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('Create howto moderation emails', () => {
expect(html).toContain('Mock Howto')
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct PP signoff
expect(html).toContain(PP_SIGNOFF)
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Create howto moderation emails', () => {
expect(html).toContain('Mock Howto')
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct PP signoff
expect(html).toContain(PP_SIGNOFF)
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Create howto moderation emails', () => {
)
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct PP signoff
expect(html).toContain(PP_SIGNOFF)
Expand Down Expand Up @@ -225,11 +225,11 @@ describe('Create howto moderation emails', () => {
expect(html).toContain('Mock Howto')
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct howto guidelines link
expect(html).toContain(
'https://community.preciousplastic.com/academy/create/howto',
'https://community.preciousplastic.com/academy/create/library',
)
expect(html).toContain(MOCK_HOW_TO_MODERATION_COMMENT)
// Check that the email contains the correct PP signoff
Expand Down
20 changes: 11 additions & 9 deletions functions/src/emailNotifications/createModerationEmails.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import * as functions from 'firebase-functions'
import { QueryDocumentSnapshot } from 'firebase-admin/firestore'
import { IModerationStatus, IModerable } from 'oa-shared'
import { IModerationStatus } from 'oa-shared'

import { withErrorAlerting } from '../alerting/errorAlerting'
import { MEMORY_LIMIT_512_MB } from '../consts'
import { db } from '../Firebase/firestoreDB'
import { DB_ENDPOINTS } from '../models'
import * as templates from './templateHelpers'
import { getUserAndEmail } from './utils'
import { Change } from 'firebase-functions/v1'
import { withErrorAlerting } from '../alerting/errorAlerting'
import { MEMORY_LIMIT_512_MB } from '../consts'
import { IHowtoDB } from 'oa-shared/models/howto'
import { IMapPin } from 'oa-shared/models/maps'

import type { QueryDocumentSnapshot } from 'firebase-admin/firestore'
import type { Change } from 'firebase-functions/v1'
import type { ILibrary, IModerable } from 'oa-shared'
import type { IMapPin } from 'oa-shared/models/maps'

export async function handleModerationUpdate<T extends IModerable>(
change: Change<QueryDocumentSnapshot<T>>,
Expand All @@ -24,7 +26,7 @@ export async function handleModerationUpdate<T extends IModerable>(
}
}

export async function createHowtoModerationEmail(howto: IHowtoDB) {
export async function createHowtoModerationEmail(howto: ILibrary.DB) {
const { toUser, toUserEmail } = await getUserAndEmail(howto._createdBy)

if (howto.moderation === IModerationStatus.ACCEPTED) {
Expand All @@ -33,7 +35,7 @@ export async function createHowtoModerationEmail(howto: IHowtoDB) {
message: templates.getHowToApprovalEmail(toUser, howto),
})
} else if (howto.moderation === IModerationStatus.AWAITING_MODERATION) {
// If a how to is resumbitted, send another submission confirmation email.
// If a library project is resumbitted, send another submission confirmation email.
await db.collection(DB_ENDPOINTS.emails).add({
to: toUserEmail,
message: templates.getHowToSubmissionEmail(toUser, howto),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('create email test', () => {
userId: 'user_1',
},
relevantUrl: '/test',
title: 'Test how-to',
title: 'Test project',
type: 'new_comment_discussion',
}),
notificationFactory('user_2', 'notification_2', {
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('create email test', () => {
userId: 'user_1',
},
relevantUrl: '/test',
title: 'Test how-to',
title: 'Test project',
type: 'new_comment_discussion',
}),
]
Expand Down Expand Up @@ -218,8 +218,8 @@ describe('create email test', () => {
to,
} = doc.data()
expect(html).toContain('https://community.preciousplastic.com/test')
// 1st notification: how-to
expect(html).toContain('how-to')
// 1st notification: project
expect(html).toContain('project')
expect(html).toContain('https://community.preciousplastic.com/u/user_2')
// 2nd notification: new comment
expect(html).toContain('New comment')
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('create email test', () => {
// 1st notification: new comment
expect(html).toContain('New comment')
expect(html).toContain('https://community.preciousplastic.com/u/user_1')
expect(html).toContain('Test how-to')
expect(html).toContain('Test project')
// 2nd notification: new comment
expect(html).toContain('https://community.preciousplastic.com/u/user_3')
expect(html).toContain('Test research')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('Create howto submission emails', () => {
})
})

it('Does not create email for draft how tos', async () => {
it('Does not create email for draft projects', async () => {
const howto = getMockHowto('user_1', IModerationStatus.DRAFT)
await createHowtoSubmissionEmail(howto)

Expand Down
7 changes: 3 additions & 4 deletions functions/src/emailNotifications/createSubmissionEmails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
getSenderMessageEmail,
} from './templateHelpers'
import { getUserAndEmail, isValidMessageRequest } from './utils'
import { IMessageDB } from 'oa-shared/models/messages'
import { IHowtoDB } from 'oa-shared/models/howto'
import { IMapPin } from 'oa-shared/models/maps'

import type { ILibrary, IMapPin, IMessageDB } from 'oa-shared'

export async function createMessageEmails(message: IMessageDB) {
const isValid = await isValidMessageRequest(message)
Expand All @@ -38,7 +37,7 @@ export async function createMessageEmails(message: IMessageDB) {
}
}

export async function createHowtoSubmissionEmail(howto: IHowtoDB) {
export async function createHowtoSubmissionEmail(howto: ILibrary.DB) {
const { toUser, toUserEmail } = await getUserAndEmail(howto._createdBy)

if (howto.moderation === IModerationStatus.AWAITING_MODERATION) {
Expand Down
Loading

0 comments on commit 9423027

Please sign in to comment.