Commit 25062faa authored by axet's avatar axet 🍄

migrate from appspot to firebase functions

parent 2d9edbf4
Pipeline #34027370 canceled with stage
......@@ -2,9 +2,9 @@
set -e
PATH=$PATH:./node_modules/.bin
PATH=$PATH:$PWD/node_modules/.bin
[ -z "$(which firebase)" ] && npm install firebase-tools
which firebase || npm install firebase-tools
# firebase login
......
......@@ -22,3 +22,30 @@ exports.deleteOldUsers = functions.database.ref('users/{userId}').onCreate((snap
return ref.update(updates); // execute all updates in one go and return the result to end the function
});
});
exports.topics = functions.https.onRequest((req, res) => {
let message;
switch (req.get('content-type')) {
case 'application/json':
message = req.body;
break;
case 'application/octet-stream':
message = JSON.parse(req.body.toString()) ; // Convert buffer to a string
break;
case 'text/plain':
message = JSON.parse(req.body);
break;
case 'application/x-www-form-urlencoded':
message = JSON.parse(req.body);
break;
}
if (!message)
return;
admin.messaging().send(message);
});
......@@ -98,7 +98,7 @@ global.deleteall = function deleteall(thread) {
}
function command(cmd) {
var url = "https://android-sms-gate.appspot.com/";
var url = "https://us-central1-android-sms-gate.cloudfunctions.net/topics";
var ref = "/topics/" + CRYPTO.address(current.key);
var json = {
"to" : ref,
......
......@@ -4,18 +4,12 @@ set -e
export PATH=$PATH:$PWD/node_modules/.bin/
echo $PATH
which minify || npm install minifier
MINIFY=$(which minify)
if [ -z "$MINIFY" ]; then
sudo npm install -g minifier
fi
BROWSERIFY=$(which browserify)
if [ -z "$BROWSERIFY" ]; then
sudo npm install -g browserify
fi
which browserify || npm install browserify
npm install
browserify index.js -o smsgate.js
minify jquery.viewbox.js
{
"devDependencies": {
"requirejs" : "2.2.0",
"browserify":"13.1.0",
"bitcore-lib":"0.13.19",
"bs58":"2.0.0",
"ischanged":"1.0.18",
"checkup":"1.3.0",
"bitcore-lib":"0.13.19",
"source-map":"0.5.6",
"bitcore-ecies":"https://gitlab.com/axet/bitcore-ecies",
"bitcoinjs-lib":"2.3.0",
"firebase":"3.3.0",
"minifier":"0.8.0",
"node-uuid":"1.4.7"
"bitcoinjs-lib": "2.3.0",
"bitcore-ecies": "https://gitlab.com/axet/bitcore-ecies",
"bitcore-lib": "0.13.19",
"browserify": "^13.1.0",
"bs58": "2.0.0",
"checkup": "1.3.0",
"firebase": "3.3.0",
"ischanged": "1.0.18",
"minifier": "^0.8.0",
"node-uuid": "1.4.7",
"requirejs": "2.2.0",
"source-map": "0.5.6"
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment