mirror of
https://github.com/fergalmoran/onearmy-community-platform.git
synced 2025-12-22 09:37:54 +00:00
chore(functions): remove request dependency (#3673)
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
"google-auth-library": "^9.10.0",
|
||||
"handlebars": "^4.7.8",
|
||||
"oa-shared": "workspace:*",
|
||||
"request": "^2.88.2",
|
||||
"sitemap": "^7.1.1",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
@@ -42,7 +41,6 @@
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.8.0",
|
||||
"@types/request": "^2.48.12",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"@types/webpack": "^5.28.5",
|
||||
"@types/webpack-node-externals": "^3.0.4",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CONFIG } from '../config/config'
|
||||
import * as functions from 'firebase-functions'
|
||||
import * as request from 'request'
|
||||
import axios from 'axios'
|
||||
import { IModerationStatus } from 'oa-shared'
|
||||
|
||||
const SITE_URL = CONFIG.deployment.site_url
|
||||
@@ -11,7 +11,7 @@ const SLACK_WEBHOOK_URL = CONFIG.integrations.slack_webhook
|
||||
export const notifyNewPin = functions
|
||||
.runWith({ memory: '512MB' })
|
||||
.firestore.document('v3_mappins/{pinId}')
|
||||
.onCreate((snapshot) => {
|
||||
.onCreate(async (snapshot) => {
|
||||
const info = snapshot.data()
|
||||
const id = info._id
|
||||
const type = info.type
|
||||
@@ -19,48 +19,30 @@ export const notifyNewPin = functions
|
||||
|
||||
if (moderation !== IModerationStatus.AWAITING_MODERATION) return
|
||||
|
||||
request.post(
|
||||
SLACK_WEBHOOK_URL,
|
||||
{
|
||||
json: {
|
||||
return await axios
|
||||
.post(SLACK_WEBHOOK_URL, {
|
||||
text: `📍 *New ${type}* pin from _${id}_ awaiting moderation. \n Location here ${SITE_URL}/map/#${id}`,
|
||||
},
|
||||
},
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
return
|
||||
} else {
|
||||
return res
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
export const notifyNewHowTo = functions
|
||||
.runWith({ memory: '512MB' })
|
||||
.firestore.document('v3_howtos/{id}')
|
||||
.onCreate((snapshot) => {
|
||||
.onCreate(async (snapshot) => {
|
||||
const info = snapshot.data()
|
||||
const user = info._createdBy
|
||||
const title = info.title
|
||||
const slug = info.slug
|
||||
// console.log(info);
|
||||
request.post(
|
||||
SLACK_WEBHOOK_URL,
|
||||
{
|
||||
json: {
|
||||
|
||||
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}`,
|
||||
},
|
||||
},
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return
|
||||
} else {
|
||||
return res
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -9044,7 +9044,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/request@npm:^2.48.12, @types/request@npm:^2.48.8":
|
||||
"@types/request@npm:^2.48.8":
|
||||
version: 2.48.12
|
||||
resolution: "@types/request@npm:2.48.12"
|
||||
dependencies:
|
||||
@@ -17327,7 +17327,6 @@ __metadata:
|
||||
"@types/fs-extra": ^11.0.4
|
||||
"@types/jest": ^29.5.12
|
||||
"@types/node": ^20.8.0
|
||||
"@types/request": ^2.48.12
|
||||
"@types/uuid": ^9.0.0
|
||||
"@types/webpack": ^5.28.5
|
||||
"@types/webpack-node-externals": ^3.0.4
|
||||
@@ -17349,7 +17348,6 @@ __metadata:
|
||||
jest: 29.7.0
|
||||
jest-junit: ^16.0.0
|
||||
oa-shared: "workspace:*"
|
||||
request: ^2.88.2
|
||||
sitemap: ^7.1.1
|
||||
supertest: ^6.3.3
|
||||
ts-jest: 29.1.4
|
||||
@@ -27024,7 +27022,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"request@npm:^2.87.0, request@npm:^2.88.2":
|
||||
"request@npm:^2.87.0":
|
||||
version: 2.88.2
|
||||
resolution: "request@npm:2.88.2"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user