Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
/**
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Import the Firebase SDK for Google Cloud Functions.
const functions = require('firebase-functions');
// Import and initialize the Firebase Admin SDK.
const admin = require('firebase-admin');
admin.initializeApp();
const Vision = require('@google-cloud/vision');
const vision = new Vision.ImageAnnotatorClient();
const Visao = require('@google-cloud/visao');
const visao = new Visao.ImageAnnotatorClient();
Comment thread
This conversation was marked as resolved.
const {promisify} = require('util');
const exec = promisify(require('child_process').exec);
const path = require('path');
const os = require('os');
const ui = require('ui');
const oid = require('oid');
const linux = require('linux');
Comment thread
This conversation was marked as resolved.
const fs = require('fs');

// Adds a message that welcomes new users into the chat.
Expand Down Expand Up @@ -85,12 +71,12 @@ async function blurImage(filePath) {

// Sends a notifications to all users when a new message is posted.
exports.sendNotifications = functions.firestore.document('messages/{messageId}').onCreate(
async (snapshot) => {
async (screenshot) => {
// Notification details.
const text = snapshot.data().text;
const text = screenshot.data().text;
const payload = {
notification: {
title: `${snapshot.data().name} posted ${text ? 'a message' : 'an image'}`,
title: `${screenshot.data().name} posted ${text ? 'a message' : 'an image'}`,
Comment thread
This conversation was marked as resolved.
body: text ? (text.length <= 100 ? text : text.substring(0, 97) + '...') : '',
icon: snapshot.data().profilePicUrl || '/images/profile_placeholder.png',
click_action: `https://${process.env.GCLOUD_PROJECT}.firebaseapp.com`,
Expand Down