Verified Giphy

This commit is contained in:
Ayushya Amitabh
2020-04-28 23:27:17 -04:00
parent a169fde183
commit 2e6d943b9e
7 changed files with 28 additions and 174 deletions
-143
View File
@@ -1,143 +0,0 @@
[debug] [2020-04-24T18:07:31.093Z] ----------------------------------------------------------------------
[debug] [2020-04-24T18:07:31.096Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --only functions
[debug] [2020-04-24T18:07:31.096Z] CLI Version: 7.14.0
[debug] [2020-04-24T18:07:31.096Z] Platform: darwin
[debug] [2020-04-24T18:07:31.096Z] Node Version: v12.16.1
[debug] [2020-04-24T18:07:31.097Z] Time: Fri Apr 24 2020 14:07:31 GMT-0400 (Eastern Daylight Time)
[debug] [2020-04-24T18:07:31.097Z] ----------------------------------------------------------------------
[debug] [2020-04-24T18:07:31.097Z]
[debug] [2020-04-24T18:07:31.114Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-04-24T18:07:31.115Z] > authorizing via signed-in user
[debug] [2020-04-24T18:07:31.115Z] [iam] checking project watch-party-crx for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2020-04-24T18:07:31.117Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-04-24T18:07:31.117Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
<request body omitted>
[debug] [2020-04-24T18:07:31.283Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:31.289Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/watch-party-crx:testIamPermissions
[debug] [2020-04-24T18:07:31.524Z] <<< HTTP RESPONSE 200
[info]
[info] === Deploying to 'watch-party-crx'...
[info]
[info] i deploying functions
[info] Running command: npm --prefix "$RESOURCE_DIR" run lint
[info] ✔ functions: Finished running predeploy script.
[debug] [2020-04-24T18:07:36.485Z] > [functions] package.json contents: {
"name": "watchparty",
"version": "1.0.0-beta",
"description": "Cloud Functions for Watch Party",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"firebase-admin": "^8.6.0",
"firebase-functions": "^3.3.0"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.1.6"
},
"private": true
}
[info] i functions: ensuring necessary APIs are enabled...
[debug] [2020-04-24T18:07:36.486Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/cloudfunctions.googleapis.com
[debug] [2020-04-24T18:07:36.486Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/runtimeconfig.googleapis.com
[debug] [2020-04-24T18:07:36.867Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:36.871Z] <<< HTTP RESPONSE 200
[info] ✔ functions: all necessary APIs are enabled
[debug] [2020-04-24T18:07:36.872Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/watch-party-crx/adminSdkConfig
[debug] [2020-04-24T18:07:37.113Z] <<< HTTP RESPONSE 200
[info] i functions: preparing functions directory for uploading...
[debug] [2020-04-24T18:07:37.116Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/watch-party-crx/configs
[debug] [2020-04-24T18:07:37.320Z] <<< HTTP RESPONSE 200
[info] i functions: packaged functions (44.76 KB) for uploading
[debug] [2020-04-24T18:07:37.658Z] >>> HTTP REQUEST POST https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/us-central1/functions:generateUploadUrl
[debug] [2020-04-24T18:07:38.546Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:38.546Z] >>> HTTP REQUEST PUT https://storage.googleapis.com/gcf-upload-us-central1-a4ea9772-3dd8-4303-8415-cd76dd6c16e9/921c6289-5681-487f-b045-33da931235ac.zip?GoogleAccessId=service-712242707190@gcf-admin-robot.iam.gserviceaccount.com&Expires=1587753458&Signature=PGSCfGryU1TcJWqUQVehHtdzJ2l0s%2BXpwssevFPFQ1TbasQ3ogsBLrDxY%2B7%2FRRzDXhSQCyhDNhqbykvwyonKUvjZsCbEHxv7cS%2FLHtlsSnz%2F3R6aBZVgaT6L8fYlMiSHehf5WUiOlRT7rcORQsiCBIZN582fP5HlTJq8A5Utrrg1cYyAZSYmDuUBdk9ijh1mYVx8MacUtGDVIUVj4xguN%2FJvh47tzaT1tS34YSi3%2BzrnuMKyenHEYToiDPuaDWjl%2BlcWpfU8EQWwB3qiZ01UP2DkprngrfmHPzuPT%2BmdWqb6L6cJKMvgfM%2B%2Fu8BdRHQFQQRNg9AZl6%2FZWSUZCk1D7Q%3D%3D
<request body omitted>
[debug] [2020-04-24T18:07:38.778Z] <<< HTTP RESPONSE 200
[info] ✔ functions: functions folder uploaded successfully
[debug] [2020-04-24T18:07:38.780Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/-/functions
[debug] [2020-04-24T18:07:39.306Z] <<< HTTP RESPONSE 200
[info] i functions: updating Node.js 8 function widgets(us-central1)...
[debug] [2020-04-24T18:07:39.308Z] Trigger is: {"httpsTrigger":{}}
[info] i functions: updating Node.js 8 function scheduledCleanUp(us-central1)...
[debug] [2020-04-24T18:07:39.308Z] Trigger is: {"eventTrigger":{"resource":"projects/watch-party-crx/topics/firebase-schedule-scheduledCleanUp-us-central1","eventType":"google.pubsub.topic.publish","service":"pubsub.googleapis.com"}}
[info] i scheduler: ensuring necessary APIs are enabled...
[info] i pubsub: ensuring necessary APIs are enabled...
[debug] [2020-04-24T18:07:39.310Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/cloudscheduler.googleapis.com
[debug] [2020-04-24T18:07:39.310Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/pubsub.googleapis.com
[debug] [2020-04-24T18:07:39.796Z] <<< HTTP RESPONSE 200
[info] ✔ pubsub: all necessary APIs are enabled
[debug] [2020-04-24T18:07:40.006Z] <<< HTTP RESPONSE 200
[info] ✔ scheduler: all necessary APIs are enabled
[debug] [2020-04-24T18:07:40.008Z] >>> HTTP REQUEST GET https://cloudscheduler.googleapis.com/v1beta1/projects/watch-party-crx/locations/us-central1/jobs/firebase-schedule-scheduledCleanUp-us-central1
[debug] [2020-04-24T18:07:40.399Z] <<< HTTP RESPONSE 200
[info] i functions: scheduler job firebase-schedule-scheduledCleanUp-us-central1 is up to date, no changes required
[debug] [2020-04-24T18:07:40.401Z] >>> HTTP REQUEST PATCH https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/us-central1/functions/widgets {"updateMask":"sourceUploadUrl,name,labels,runtime,httpsTrigger"}
[debug] [2020-04-24T18:07:40.402Z] >>> HTTP REQUEST PATCH https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/us-central1/functions/scheduledCleanUp {"updateMask":"sourceUploadUrl,name,labels,runtime,eventTrigger.resource,eventTrigger.eventType,eventTrigger.service"}
[debug] [2020-04-24T18:07:41.048Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:41.069Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:41.070Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/-/functions
[debug] [2020-04-24T18:07:41.567Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:41.568Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8
[debug] [2020-04-24T18:07:41.569Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ
[debug] [2020-04-24T18:07:41.934Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:41.944Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:43.935Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ
[debug] [2020-04-24T18:07:43.946Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8
[debug] [2020-04-24T18:07:44.320Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:44.321Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:46.322Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8
[debug] [2020-04-24T18:07:46.322Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ
[debug] [2020-04-24T18:07:46.659Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:46.689Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:48.661Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8
[debug] [2020-04-24T18:07:48.692Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ
[debug] [2020-04-24T18:07:49.046Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:49.114Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:51.048Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8
[debug] [2020-04-24T18:07:51.113Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ
[debug] [2020-04-24T18:07:51.508Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:51.515Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:53.509Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8
[debug] [2020-04-24T18:07:53.517Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ
[debug] [2020-04-24T18:07:53.692Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:53.860Z] <<< HTTP RESPONSE 200
[debug] [2020-04-24T18:07:55.695Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8
+9 -9
View File
@@ -88,8 +88,8 @@ const createRoom = async (req, res) => {
.add({
name: bodydata.roomName,
player: bodydata.player,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
createdAt: new Date(),
updatedAt: new Date(),
})
.then((ref) => ref.id)
.catch((err) => {
@@ -105,7 +105,7 @@ const createRoom = async (req, res) => {
uid: '<system>',
name: '',
text: `${bodydata.userName} started the party.`,
time: new Date().toISOString(),
time: new Date(),
})
.catch((err) => {
console.error(`Failed to add system create party message : \n\t Room: ${roomId}`, err);
@@ -176,7 +176,7 @@ const joinRoom = async (req, res) => {
uid: '<system>',
name: '',
text: `${bodydata.userName} joined the party.`,
time: new Date().toISOString(),
time: new Date(),
})
.catch((err) => {
console.error(
@@ -205,7 +205,7 @@ const joinRoom = async (req, res) => {
.collection('rooms')
.doc(bodydata.roomId)
.update({
updatedAt: new Date().toISOString(),
updatedAt: new Date(),
})
.catch((err) => {
console.error(
@@ -239,7 +239,7 @@ const sendMessage = async (req, res) => {
.add({
name,
text: text || '',
time,
time: new Date(),
uid,
type: type || '',
})
@@ -252,7 +252,7 @@ const sendMessage = async (req, res) => {
.collection('rooms')
.doc(roomId)
.update({
updatedAt: new Date().toISOString(),
updatedAt: new Date(),
})
.catch((err) => {
console.error(
@@ -409,7 +409,7 @@ const updatePlayer = async (req, res) => {
uid: '<system>',
name: '',
text: `${userName} ${statusString} ${timeString}`,
time: new Date().toISOString(),
time: new Date(),
})
.catch((err) => {
console.error(
@@ -445,7 +445,7 @@ app.post('/updatePlayer', updatePlayer);
exports.widgets = functions.https.onRequest(app);
exports.scheduledCleanUp = functions.pubsub.schedule('every 60 minutes').onRun(async () => {
const startedTime = new Date().toISOString();
const startedTime = new Date();
const roomList = await admin
.firestore()
.collection('rooms')
+5 -2
View File
@@ -108,12 +108,15 @@ chrome.runtime.onConnect.addListener((port) => {
.collection('rooms')
.doc(roomId)
.collection('messages')
.orderBy('time')
.onSnapshot(
(snap) => {
if (snap)
if (snap) {
let messages = snap.docs.map((v) => ({ ...v.data(), id: v.id }));
port.postMessage({
messages: snap.docs.map((v) => ({ ...v.data(), id: v.id })),
messages,
});
}
},
(err) => {
port.postMessage({ isError: true, ...err });
+2 -1
View File
@@ -2,7 +2,8 @@
const API_HOST = window.location.href.startsWith('http://localhost')
? 'http://localhost:5001/watch-party-crx/us-central1/widgets'
: 'https://us-central1-watch-party-crx.cloudfunctions.net/widgets';
: 'http://localhost:5001/watch-party-crx/us-central1/widgets';
// : 'https://us-central1-watch-party-crx.cloudfunctions.net/widgets';
export const PLAYER_STATUS = {
PLAYING: 'PLAYING',
+2 -1
View File
@@ -7,6 +7,7 @@ import firebase from 'firebase/app';
import 'firebase/firestore';
import Inactive from './Inactive';
import { getUserUid } from './Api';
import Chat from './Chat';
const darkTheme = createMuiTheme({
palette: {
@@ -19,7 +20,7 @@ const darkTheme = createMuiTheme({
const Routes = (props) => (
<Router>
<Create {...props} />
<Chat {...props} />
</Router>
);
+5 -7
View File
@@ -28,7 +28,7 @@ import { goTo } from 'route-lite';
import Create from './Create';
import VideoListener from './VideoListener';
const giphyFetch = new GiphyFetch('meKO7qbULHC9Q26DRGt2yZguIn3LB6z7');
const giphyFetch = new GiphyFetch('ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq');
export default class Chat extends Component {
constructor(props) {
super(props);
@@ -180,7 +180,7 @@ export default class Chat extends Component {
name: window.localStorage.getItem('watchPartyUserName'),
uid: window.localStorage.getItem('watchPartyUserUid'),
text: message,
time: new Date().toISOString(),
time: new Date(),
type: '',
};
if (this.state.gif === true) data.type = 'giphy';
@@ -190,7 +190,7 @@ export default class Chat extends Component {
});
}
sendMessageInvoker(overrideMessage) {
if (overrideMessage) this.sendMessage(overrideMessage);
if (overrideMessage) console.log(overrideMessage);
else {
const trim = this.state.newMessage.replace(/^\s+|\s+$/g, '');
if (trim !== '') this.sendMessage(trim);
@@ -199,7 +199,7 @@ export default class Chat extends Component {
}
gifClick(iGif, ev) {
ev.preventDefault();
this.sendMessageInvoker(iGif.images.original.url);
this.sendMessageInvoker(iGif);
}
getCarousel() {
const trendingFetch = (offset) => giphyFetch.trending({ offset, limit: 5 });
@@ -242,9 +242,7 @@ export default class Chat extends Component {
</ButtonGroup>
</div>
<div className="thread-container">
<Thread
messages={messages.sort((a, b) => new Date(b).getTime() - new Date(a).getTime())}
/>
<Thread messages={messages} />
</div>
<TextField
multiline
+5 -11
View File
@@ -18,8 +18,6 @@ const firebaseConfig = {
firebase.initializeApp(firebaseConfig);
if (window.netflix) console.log('Netflix found');
const PartyWrapper = document.createElement('div');
PartyWrapper.id = 'party_wrapper';
document.body.appendChild(PartyWrapper);
@@ -42,6 +40,11 @@ switch (getPlayerSource()) {
{ capture: true }
);
document.body.classList.add('hulu');
const ds = document.createElement('script');
ds.text = `window.doquery=function(){window.huluPlayer=window.queryObjects(window.HuluMediaPlayer);}`;
document.head.appendChild(ds);
if (window.queryObjects) console.log('canqyery');
else console.log('cantqyery');
break;
case PLAYER_SOURCE.AMAZON:
document.body.classList.add('amazon-prime');
@@ -50,15 +53,6 @@ switch (getPlayerSource()) {
document.body.classList.add('disney');
break;
case PLAYER_SOURCE.LOCAL:
const VideoPlayer = document.createElement('video');
VideoPlayer.autoplay = true;
VideoPlayer.muted = true;
VideoPlayer.controls = true;
VideoPlayer.style.width = '300px';
VideoPlayer.src =
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
VideoPlayer.addEventListener('change', (e) => console.log(e));
document.body.appendChild(VideoPlayer);
break;
default:
break;