Skip to content

Commit

Permalink
firebase api_key deleted from github, server side uploaded + deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
liorva committed Jun 18, 2018
1 parent 090b568 commit 28da4bc
Show file tree
Hide file tree
Showing 10 changed files with 4,256 additions and 13 deletions.
3 changes: 2 additions & 1 deletion AgudaApp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ dist/
tmp/
temp/
hooks/
functions/
functions/node_modules/
src/app/app.firebase.config.ts

$RECYCLE.BIN/

Expand Down
3,995 changes: 3,995 additions & 0 deletions AgudaApp/functions/package-lock.json

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions AgudaApp/functions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "~5.12.0",
"firebase-functions": "^1.0.1"
},
"devDependencies": {
"tslint": "^5.8.0",
"typescript": "^2.5.3"
},
"private": true
}
98 changes: 98 additions & 0 deletions AgudaApp/functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

admin.initializeApp(functions.config().firebase);

export const newGeneralNotification = functions.firestore
.document('Notifications/notidicationID').onUpdate(async event => {
const data = event.after.data();
const msg = data.message;

const payload = {
notification: {
title: msg,
sound: 'default',
icon: 'ic_stat_normal',
clickAction: "FCM_PLUGIN_ACTIVITY"
},

data: {
title: msg
}
}

const options = {
priority: "high",
timeToLive: 60 * 60 * 24 //24 hours
};

return admin.messaging().sendToTopic('pushes', payload, options);
})

export const newStoryNotification = functions.firestore
.document('HomeStories/{storyID}').onCreate(async event => {

const data = event.data();

const headline = data.headline;
const prev = data.preview;

const payload = {
notification: {
title: headline,
body: prev,
sound: 'default',
icon: 'ic_stat_normal',
clickAction: "FCM_PLUGIN_ACTIVITY"
},

data: {
title: headline,
body: prev,
}
}

const options = {
priority: "high",
timeToLive: 60 * 60 * 24 //24 hours
};

return admin.messaging().sendToTopic('pushes', payload, options);
})

export const newEventNotification = functions.firestore
.document('Events/{eventID}').onCreate(async event => {

const data = event.data();

const preTitle = "אירוע חדש בתאריך";
const bodyMsg = data.headline;
const temp = data.date.split(" ")[0];

const year = temp.split("/")[0];
const month = temp.split("/")[1];
const day = temp.split("/")[2];

const date = day + "/" + month + "/" + year;

const payload = {
notification: {
title: preTitle + " " + date + " ",
body: bodyMsg,
sound: 'default',
icon: 'ic_stat_normal',
clickAction: "FCM_PLUGIN_ACTIVITY"
},

data: {
title: "אירוע חדש!" + "\n" + bodyMsg + "\n\n" + "מתי? " + date + ", " + data.date.split(" ")[1].substring(0, 5) + "\nהיכנסו ללוח אירועים לפרטים נוספים.",
}
}

const options = {
priority: "high",
timeToLive: 60 * 60 * 24 //24 hours
};

return admin.messaging().sendToTopic('pushes', payload, options);
})
14 changes: 14 additions & 0 deletions AgudaApp/functions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"lib": ["es6"],
"module": "commonjs",
"noImplicitReturns": true,
"outDir": "lib",
"sourceMap": true,
"target": "es6"
},
"compileOnSave": true,
"include": [
"src"
]
}
121 changes: 121 additions & 0 deletions AgudaApp/functions/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"rules": {
// -- Strict errors --
// These lint rules are likely always a good idea.

// Force function overloads to be declared together. This ensures readers understand APIs.
"adjacent-overload-signatures": true,

// Do not allow the subtle/obscure comma operator.
"ban-comma-operator": true,

// Do not allow internal modules or namespaces . These are deprecated in favor of ES6 modules.
"no-namespace": true,

// Do not allow parameters to be reassigned. To avoid bugs, developers should instead assign new values to new vars.
"no-parameter-reassignment": true,

// Force the use of ES6-style imports instead of /// <reference path=> imports.
"no-reference": true,

// Do not allow type assertions that do nothing. This is a big warning that the developer may not understand the
// code currently being edited (they may be incorrectly handling a different type case that does not exist).
"no-unnecessary-type-assertion": true,

// Disallow nonsensical label usage.
"label-position": true,

// Disallows the (often typo) syntax if (var1 = var2). Replace with if (var2) { var1 = var2 }.
"no-conditional-assignment": true,

// Disallows constructors for primitive types (e.g. new Number('123'), though Number('123') is still allowed).
"no-construct": true,

// Do not allow super() to be called twice in a constructor.
"no-duplicate-super": true,

// Do not allow the same case to appear more than once in a switch block.
"no-duplicate-switch-case": true,

// Do not allow a variable to be declared more than once in the same block. Consider function parameters in this
// rule.
"no-duplicate-variable": [true, "check-parameters"],

// Disallows a variable definition in an inner scope from shadowing a variable in an outer scope. Developers should
// instead use a separate variable name.
"no-shadowed-variable": true,

// Empty blocks are almost never needed. Allow the one general exception: empty catch blocks.
"no-empty": [true, "allow-empty-catch"],

// Functions must either be handled directly (e.g. with a catch() handler) or returned to another function.
// This is a major source of errors in Cloud Functions and the team strongly recommends leaving this rule on.
"no-floating-promises": true,

// Do not allow any imports for modules that are not in package.json. These will almost certainly fail when
// deployed.
"no-implicit-dependencies": true,

// The 'this' keyword can only be used inside of classes.
"no-invalid-this": true,

// Do not allow strings to be thrown because they will not include stack traces. Throw Errors instead.
"no-string-throw": true,

// Disallow control flow statements, such as return, continue, break, and throw in finally blocks.
"no-unsafe-finally": true,

// Do not allow variables to be used before they are declared.
"no-use-before-declare": true,

// Expressions must always return a value. Avoids common errors like const myValue = functionReturningVoid();
"no-void-expression": [true, "ignore-arrow-function-shorthand"],

// Disallow duplicate imports in the same file.
"no-duplicate-imports": true,


// -- Strong Warnings --
// These rules should almost never be needed, but may be included due to legacy code.
// They are left as a warning to avoid frustration with blocked deploys when the developer
// understand the warning and wants to deploy anyway.

// Warn when an empty interface is defined. These are generally not useful.
"no-empty-interface": {"severity": "warning"},

// Warn when an import will have side effects.
"no-import-side-effect": {"severity": "warning"},

// Warn when variables are defined with var. Var has subtle meaning that can lead to bugs. Strongly prefer const for
// most values and let for values that will change.
"no-var-keyword": {"severity": "warning"},

// Prefer === and !== over == and !=. The latter operators support overloads that are often accidental.
"triple-equals": {"severity": "warning"},

// Warn when using deprecated APIs.
"deprecation": {"severity": "warning"},

// -- Light Warnigns --
// These rules are intended to help developers use better style. Simpler code has fewer bugs. These would be "info"
// if TSLint supported such a level.

// prefer for( ... of ... ) to an index loop when the index is only used to fetch an object from an array.
// (Even better: check out utils like .map if transforming an array!)
"prefer-for-of": {"severity": "warning"},

// Warns if function overloads could be unified into a single function with optional or rest parameters.
"unified-signatures": {"severity": "warning"},

// Warns if code has an import or variable that is unused.
"no-unused-variable": {"severity": "warning"},

// Prefer const for values that will not change. This better documents code.
"prefer-const": {"severity": "warning"},

// Multi-line object liiterals and function calls should have a trailing comma. This helps avoid merge conflicts.
"trailing-comma": {"severity": "warning"}
},

"defaultSeverity": "error"
}
2 changes: 1 addition & 1 deletion AgudaApp/platforms/browser/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="jce.aguda.teamcal" version="0.9.6" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="jce.aguda.teamcal" version="1.0.6" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>אגודת הסטודנטים</name>
<description>.אפליקציית המידע של אגודת הסטודנטים - עזריאלי, המכללה האקדמית להנדסה ירושלים</description>
<author email="[email protected]" href="https://www.google.co.il/">TeamCal Appz.</author>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="jce.aguda.teamcal" version="0.9.6" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="jce.aguda.teamcal" version="1.0.6" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9.6</string>
<string>1.0.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.9.6</string>
<string>1.0.6</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
Expand Down
8 changes: 0 additions & 8 deletions AgudaApp/src/app/app.firebase.config.ts

This file was deleted.

0 comments on commit 28da4bc

Please sign in to comment.