From dd9d83f7e52c82d3648038d760d8c86b352a2096 Mon Sep 17 00:00:00 2001 From: Mitar Date: Sun, 13 Nov 2016 04:25:07 -0800 Subject: [PATCH 01/49] Initial support for e-mail notifications. --- .meteor/versions | 2 +- packages/api/activity/publish.coffee | 17 +- packages/core/documents/activity.coffee | 23 + packages/core/documents/email.coffee | 34 + packages/core/package.js | 4 +- packages/jobs/.npm/package/.gitignore | 1 + packages/jobs/.npm/package/README | 7 + .../jobs/.npm/package/npm-shrinkwrap.json | 679 ++++++++++++++++++ packages/jobs/email.coffee | 161 +++++ packages/jobs/email.html | 32 + packages/jobs/package.js | 21 +- packages/peermind/activity/list.coffee | 8 +- packages/peermind/activity/list.html | 7 +- .../peermind/discussion/display-route.coffee | 10 + packages/peermind/discussion/display.coffee | 11 - packages/peermind/layout/header.html | 2 +- packages/peermind/layout/header.styl | 10 +- .../peermind/meeting/display-route.coffee | 7 + packages/peermind/meeting/display.coffee | 8 - packages/peermind/package.js | 13 +- packages/peermind/user/display-route.coffee | 7 + packages/peermind/user/display.coffee | 8 - 22 files changed, 1014 insertions(+), 58 deletions(-) create mode 100644 packages/core/documents/email.coffee create mode 100644 packages/jobs/.npm/package/.gitignore create mode 100644 packages/jobs/.npm/package/README create mode 100644 packages/jobs/.npm/package/npm-shrinkwrap.json create mode 100644 packages/jobs/email.coffee create mode 100644 packages/jobs/email.html create mode 100644 packages/peermind/discussion/display-route.coffee create mode 100644 packages/peermind/meeting/display-route.coffee create mode 100644 packages/peermind/user/display-route.coffee diff --git a/.meteor/versions b/.meteor/versions index 7b9f87f..1aa8389 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -93,7 +93,7 @@ peerlibrary:blaze-components@0.20.0 peerlibrary:blaze-layout-component@0.2.0 peerlibrary:blocking@0.5.2 peerlibrary:check-extension@0.2.1 -peerlibrary:classy-job@0.5.0 +peerlibrary:classy-job@0.6.1 peerlibrary:computed-field@0.6.0 peerlibrary:connect@2.28.1_1 peerlibrary:crypto@0.2.1 diff --git a/packages/api/activity/publish.coffee b/packages/api/activity/publish.coffee index f944ce6..56cd66d 100644 --- a/packages/api/activity/publish.coffee +++ b/packages/api/activity/publish.coffee @@ -1,16 +1,3 @@ -personalizedActivityQuery = (userId) -> - level: - $in: [Activity.LEVEL.USER, Activity.LEVEL.GENERAL] - 'byUser._id': - $ne: userId - $or: [ - 'forUsers._id': userId - , - # A special case, we want all users to get notifications for new discussions and meetings. - type: - $in: ['discussionCreated', 'meetingCreated'] - ] - new PublishEndpoint 'Activity.list', (personalized, initialLimit) -> check personalized, Boolean check initialLimit, Match.PositiveNumber @@ -20,7 +7,7 @@ new PublishEndpoint 'Activity.list', (personalized, initialLimit) -> userId = Meteor.userId() if personalized if userId - query = personalizedActivityQuery userId + query = Activity.personalizedActivityQuery userId else return [] else @@ -58,7 +45,7 @@ new PublishEndpoint 'Activity.unseenPersonalizedCount', -> lastSeenPersonalizedActivity.stop() @autorun (computation) => - query = personalizedActivityQuery userId + query = Activity.personalizedActivityQuery userId if lastSeenPersonalizedActivity() _.extend query, timestamp: diff --git a/packages/core/documents/activity.coffee b/packages/core/documents/activity.coffee index 9435a6e..6f50052 100644 --- a/packages/core/documents/activity.coffee +++ b/packages/core/documents/activity.coffee @@ -28,6 +28,16 @@ class Activity extends share.BaseDocument meeting: @ReferenceField Meeting, ['title'], false discussion: @ReferenceField Discussion, ['title'], false activity: @ReferenceField 'self', [], false + triggers: => + sendEmails: @Trigger ['timestamp', 'level'], (newDocument, oldDocument) -> + # Only trigger when document is created. + return unless newDocument?._id and not oldDocument + + # Small optimization, because we send e-mails only for those levels. + return unless newDocument.level in [Activity.LEVEL.USER, Activity.LEVEL.GENERAL] + + # ActivityEmailsJob is enqueued only if there is no existing job which would cover this timestamp. + new ActivityEmailsJob(fromTimestamp: newDocument.timestamp).enqueue() @LEVEL: DEBUG: 'debug' @@ -52,6 +62,19 @@ class Activity extends share.BaseDocument level: 1 data: 1 + @personalizedActivityQuery: (userId) -> + level: + $in: [Activity.LEVEL.USER, Activity.LEVEL.GENERAL] + 'byUser._id': + $ne: userId + $or: [ + 'forUsers._id': userId + , + # A special case, we want all users to get notifications for new discussions and meetings. + type: + $in: ['discussionCreated', 'meetingCreated'] + ] + # Combine documents so that consecutive activities of the same type are combined into one document. @combineActivities: (documents) -> combinedDocuments = [] diff --git a/packages/core/documents/email.coffee b/packages/core/documents/email.coffee new file mode 100644 index 0000000..14f38c7 --- /dev/null +++ b/packages/core/documents/email.coffee @@ -0,0 +1,34 @@ +if Meteor.isServer + EmailModule = require 'meteor/email' + +class Email extends share.BaseDocument + # createdAt: time of document creation + # sentAt: time when e-mail was send + # from + # to + # subject + # text + # html + # headers + + @Meta + name: 'Email' + + @send: (options) -> + throw new Error "Not supported." unless Meteor.isServer + + options = _.extend {}, options, + createdAt: new Date() + + options._id ?= Random.id() + + options.headers ?= {} + options.headers['Message-ID'] ?= "" + + @documents.insert options + + EmailModule.Email.send options + + @documents.update options._id, + $set: + sentAt: new Date() diff --git a/packages/core/package.js b/packages/core/package.js index 08afbb4..ad520a2 100644 --- a/packages/core/package.js +++ b/packages/core/package.js @@ -27,7 +27,7 @@ Package.onUse(function (api) { // TODO: There is a newer version of cheerio, but not Meteor package. Upgrade. 'fermuch:cheerio@0.19.0', 'alanning:roles@1.2.15', - 'peerlibrary:classy-job@0.5.0', + 'peerlibrary:classy-job@0.6.1', 'peerlibrary:user-extra@0.1.0', 'kenton:accounts-sandstorm@0.5.1' ]); @@ -58,6 +58,7 @@ Package.onUse(function (api) { api.export('Activity'); api.export('Admin'); api.export('Settings'); + api.export('Email'); api.addFiles([ 'worker.coffee', @@ -90,6 +91,7 @@ Package.onUse(function (api) { 'documents/jobqueue.coffee', 'documents/storagefile.coffee', 'documents/activity.coffee', + 'documents/email.coffee', 'finalize-documents.coffee' ]); diff --git a/packages/jobs/.npm/package/.gitignore b/packages/jobs/.npm/package/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/packages/jobs/.npm/package/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/packages/jobs/.npm/package/README b/packages/jobs/.npm/package/README new file mode 100644 index 0000000..3d49255 --- /dev/null +++ b/packages/jobs/.npm/package/README @@ -0,0 +1,7 @@ +This directory and the files immediately inside it are automatically generated +when you change this package's NPM dependencies. Commit the files in this +directory (npm-shrinkwrap.json, .gitignore, and this README) to source control +so that others run the same versions of sub-dependencies. + +You should NOT check in the node_modules directory that Meteor automatically +creates; if you are using git, the .gitignore file tells git to ignore it. diff --git a/packages/jobs/.npm/package/npm-shrinkwrap.json b/packages/jobs/.npm/package/npm-shrinkwrap.json new file mode 100644 index 0000000..600d31d --- /dev/null +++ b/packages/jobs/.npm/package/npm-shrinkwrap.json @@ -0,0 +1,679 @@ +{ + "dependencies": { + "abab": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.3.tgz", + "from": "abab@>=1.0.0 <2.0.0" + }, + "acorn": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", + "from": "acorn@>=2.4.0 <3.0.0" + }, + "acorn-globals": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-1.0.9.tgz", + "from": "acorn-globals@>=1.0.4 <2.0.0" + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "from": "amdefine@>=0.0.4" + }, + "ansi-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", + "from": "ansi-regex@>=2.0.0 <3.0.0" + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "from": "ansi-styles@>=2.2.1 <3.0.0" + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "from": "asn1@>=0.2.3 <0.3.0" + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "from": "assert-plus@>=0.2.0 <0.3.0" + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "from": "async@>=1.5.2 <2.0.0" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "from": "asynckit@>=0.4.0 <0.5.0" + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "from": "aws-sign2@>=0.6.0 <0.7.0" + }, + "aws4": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.5.0.tgz", + "from": "aws4@>=1.2.1 <2.0.0" + }, + "bcrypt-pbkdf": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.0.tgz", + "from": "bcrypt-pbkdf@>=1.0.0 <2.0.0" + }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "from": "boolbase@>=1.0.0 <1.1.0" + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "from": "boom@>=2.0.0 <3.0.0" + }, + "caseless": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "from": "caseless@>=0.11.0 <0.12.0" + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "from": "chalk@>=1.1.1 <2.0.0" + }, + "cheerio": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.20.0.tgz", + "from": "cheerio@0.20.0" + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "from": "combined-stream@>=1.0.5 <1.1.0" + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "from": "commander@2.9.0" + }, + "concat-stream": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", + "from": "concat-stream@>=1.4.7 <2.0.0" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "from": "core-util-is@>=1.0.0 <1.1.0" + }, + "cross-spawn": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz", + "from": "cross-spawn@>=4.0.0 <5.0.0" + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "from": "cryptiles@>=2.0.0 <3.0.0" + }, + "css-select": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "from": "css-select@>=1.2.0 <1.3.0" + }, + "css-what": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz", + "from": "css-what@>=2.1.0 <2.2.0" + }, + "cssom": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.1.tgz", + "from": "cssom@>=0.3.0 <0.4.0" + }, + "cssstyle": { + "version": "0.2.37", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-0.2.37.tgz", + "from": "cssstyle@>=0.2.29 <0.3.0" + }, + "dashdash": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.0.tgz", + "from": "dashdash@>=1.12.0 <2.0.0", + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "from": "assert-plus@>=1.0.0 <2.0.0" + } + } + }, + "datauri": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/datauri/-/datauri-0.2.1.tgz", + "from": "datauri@>=0.2.0 <0.3.0" + }, + "deep-extend": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz", + "from": "deep-extend@>=0.4.0 <0.5.0" + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "from": "deep-is@>=0.1.3 <0.2.0" + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "from": "delayed-stream@>=1.0.0 <1.1.0" + }, + "dom-serializer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", + "from": "dom-serializer@>=0.1.0 <0.2.0", + "dependencies": { + "domelementtype": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "from": "domelementtype@>=1.1.1 <1.2.0" + } + } + }, + "domelementtype": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", + "from": "domelementtype@>=1.0.0 <2.0.0" + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "from": "domhandler@>=2.3.0 <2.4.0" + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "from": "domutils@1.5.1" + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "from": "ecc-jsbn@>=0.1.1 <0.2.0" + }, + "entities": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", + "from": "entities@>=1.1.1 <1.2.0" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "from": "escape-string-regexp@>=1.0.2 <2.0.0" + }, + "escodegen": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", + "from": "escodegen@>=1.6.1 <2.0.0" + }, + "esprima": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "from": "esprima@>=2.7.1 <3.0.0" + }, + "estraverse": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "from": "estraverse@>=1.9.1 <2.0.0" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "from": "esutils@>=2.0.2 <3.0.0" + }, + "extend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", + "from": "extend@>=3.0.0 <3.1.0" + }, + "extsprintf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", + "from": "extsprintf@1.0.2" + }, + "fast-levenshtein": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.5.tgz", + "from": "fast-levenshtein@>=2.0.4 <2.1.0" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "from": "forever-agent@>=0.6.1 <0.7.0" + }, + "form-data": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.2.tgz", + "from": "form-data@>=2.1.1 <2.2.0" + }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "from": "generate-function@>=2.0.0 <3.0.0" + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "from": "generate-object-property@>=1.1.0 <2.0.0" + }, + "getpass": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.6.tgz", + "from": "getpass@>=0.1.1 <0.2.0", + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "from": "assert-plus@>=1.0.0 <2.0.0" + } + } + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "from": "graceful-readlink@>=1.0.0" + }, + "har-validator": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", + "from": "har-validator@>=2.0.6 <2.1.0" + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "from": "has-ansi@>=2.0.0 <3.0.0" + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "from": "hawk@>=3.1.3 <3.2.0" + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "from": "hoek@>=2.0.0 <3.0.0" + }, + "html": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/html/-/html-1.0.0.tgz", + "from": "html@1.0.0" + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "from": "htmlparser2@>=3.8.1 <3.9.0", + "dependencies": { + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "from": "entities@>=1.0.0 <1.1.0" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "from": "isarray@0.0.1" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "from": "readable-stream@>=1.1.0 <1.2.0" + } + } + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "from": "http-signature@>=1.1.0 <1.2.0" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "from": "inherits@>=2.0.1 <2.1.0" + }, + "is-my-json-valid": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz", + "from": "is-my-json-valid@>=2.12.4 <3.0.0" + }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "from": "is-property@>=1.0.0 <2.0.0" + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "from": "is-typedarray@>=1.0.0 <1.1.0" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "from": "isarray@>=1.0.0 <1.1.0" + }, + "isexe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz", + "from": "isexe@>=1.1.1 <2.0.0" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "from": "isstream@>=0.1.2 <0.2.0" + }, + "jodid25519": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", + "from": "jodid25519@>=1.0.0 <2.0.0" + }, + "jsbn": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.0.tgz", + "from": "jsbn@>=0.1.0 <0.2.0" + }, + "jsdom": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-7.2.2.tgz", + "from": "jsdom@>=7.0.2 <8.0.0" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "from": "json-schema@0.2.3" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "from": "json-stringify-safe@>=5.0.1 <5.1.0" + }, + "jsonpointer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.0.tgz", + "from": "jsonpointer@>=4.0.0 <5.0.0" + }, + "jsprim": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.3.1.tgz", + "from": "jsprim@>=1.2.2 <2.0.0" + }, + "juice": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/juice/-/juice-3.0.1.tgz", + "from": "juice@3.0.1" + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "from": "levn@>=0.3.0 <0.4.0" + }, + "lodash": { + "version": "4.16.6", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.16.6.tgz", + "from": "lodash@>=4.1.0 <5.0.0" + }, + "lodash.constant": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash.constant/-/lodash.constant-3.0.0.tgz", + "from": "lodash.constant@>=3.0.0 <4.0.0" + }, + "lodash.unescape": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", + "from": "lodash.unescape@>=4.0.0 <5.0.0" + }, + "lru-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.0.1.tgz", + "from": "lru-cache@>=4.0.1 <5.0.0" + }, + "mensch": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/mensch/-/mensch-0.3.3.tgz", + "from": "mensch@>=0.3.3 <0.4.0" + }, + "mime-db": { + "version": "1.24.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.24.0.tgz", + "from": "mime-db@>=1.24.0 <1.25.0" + }, + "mime-types": { + "version": "2.1.12", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.12.tgz", + "from": "mime-types@>=2.1.7 <2.2.0" + }, + "mimer": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/mimer/-/mimer-0.2.1.tgz", + "from": "mimer@*" + }, + "node-uuid": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.7.tgz", + "from": "node-uuid@>=1.4.7 <1.5.0" + }, + "nth-check": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", + "from": "nth-check@>=1.0.1 <1.1.0" + }, + "nwmatcher": { + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.3.9.tgz", + "from": "nwmatcher@>=1.3.7 <2.0.0" + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "from": "oauth-sign@>=0.8.1 <0.9.0" + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "from": "optionator@>=0.8.1 <0.9.0" + }, + "parse5": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-1.5.1.tgz", + "from": "parse5@>=1.5.1 <2.0.0" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "from": "pinkie@>=2.0.0 <3.0.0" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "from": "pinkie-promise@>=2.0.0 <3.0.0" + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "from": "prelude-ls@>=1.1.2 <1.2.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "from": "pseudomap@>=1.0.1 <2.0.0" + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "from": "punycode@>=1.4.1 <2.0.0" + }, + "qs": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz", + "from": "qs@>=6.3.0 <6.4.0" + }, + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "from": "readable-stream@>=2.0.0 <2.1.0" + }, + "request": { + "version": "2.78.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.78.0.tgz", + "from": "request@>=2.55.0 <3.0.0" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "from": "sax@>=1.1.4 <2.0.0" + }, + "slick": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/slick/-/slick-1.12.2.tgz", + "from": "slick@1.12.2" + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "from": "sntp@>=1.0.0 <2.0.0" + }, + "source-map": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "from": "source-map@>=0.2.0 <0.3.0" + }, + "sshpk": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.10.1.tgz", + "from": "sshpk@>=1.7.0 <2.0.0", + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "from": "assert-plus@>=1.0.0 <2.0.0" + } + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "from": "string_decoder@>=0.10.0 <0.11.0" + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "from": "stringstream@>=0.0.4 <0.1.0" + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "from": "strip-ansi@>=3.0.0 <4.0.0" + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "from": "supports-color@>=2.0.0 <3.0.0" + }, + "symbol-tree": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.1.4.tgz", + "from": "symbol-tree@>=3.1.0 <4.0.0" + }, + "templayed": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/templayed/-/templayed-0.2.3.tgz", + "from": "templayed@*" + }, + "tough-cookie": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "from": "tough-cookie@>=2.2.0 <3.0.0" + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "from": "tr46@>=0.0.1 <0.1.0" + }, + "tunnel-agent": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "from": "tunnel-agent@>=0.4.1 <0.5.0" + }, + "tweetnacl": { + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.3.tgz", + "from": "tweetnacl@>=0.14.0 <0.15.0" + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "from": "type-check@>=0.3.2 <0.4.0" + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "from": "typedarray@>=0.0.5 <0.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "from": "util-deprecate@>=1.0.1 <1.1.0" + }, + "verror": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", + "from": "verror@1.3.6" + }, + "web-resource-inliner": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/web-resource-inliner/-/web-resource-inliner-3.0.0.tgz", + "from": "web-resource-inliner@3.0.0" + }, + "webidl-conversions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-2.0.1.tgz", + "from": "webidl-conversions@>=2.0.0 <3.0.0" + }, + "whatwg-url-compat": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/whatwg-url-compat/-/whatwg-url-compat-0.6.5.tgz", + "from": "whatwg-url-compat@>=0.6.5 <0.7.0" + }, + "which": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.12.tgz", + "from": "which@>=1.2.9 <2.0.0" + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "from": "wordwrap@>=1.0.0 <1.1.0" + }, + "xml-name-validator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-2.0.1.tgz", + "from": "xml-name-validator@>=2.0.1 <3.0.0" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "from": "xtend@>=4.0.0 <5.0.0" + }, + "yallist": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.0.0.tgz", + "from": "yallist@>=2.0.0 <3.0.0" + } + } +} diff --git a/packages/jobs/email.coffee b/packages/jobs/email.coffee new file mode 100644 index 0000000..5dd37d2 --- /dev/null +++ b/packages/jobs/email.coffee @@ -0,0 +1,161 @@ +fs = Npm.require 'fs' +htmlModule = Npm.require 'html' +juice = Npm.require 'juice' +pathModule = Npm.require 'path' +url = Npm.require 'url' + +class ActivityEmailsComponent extends UIComponent + @register 'ActivityEmailsComponent' + + constructor: (@activities) -> + super + + instrument: -> + # TODO + +class ActivityEmailsJob extends Job + @register() + + @DELAY = 0 #60 * 1000 # ms + + enqueueOptions: (options) -> + _.defaults super, + delay: @constructor.DELAY + + shouldSkip: (options) -> + # Does a job which can run or is running exist which will handle activities for this job's timestamp as well? + !!JobsWorker.collection.findOne + 'data.fromTimestamp': + $lte: @data.fromTimestamp + $or: [ + # If a job processing this timestamp range runs on a worker with imprecise clock, then it might + # happen that toTimestamp gets assigned a timestamp before @data.fromTimestamp. In this case + # skipping this job was wrong. But this is (among other reasons) why we have that enqueue of an + # extra job at the end of run method, which should handle such a case. + 'data.toTimestamp': null + , + 'data.toTimestamp': + $gt: @data.fromTimestamp + ] + status: + $in: JobsWorker.collection.jobStatusCancellable + , + # Making findOne similar to exists. + fields: + _id: 1 + transform: null + + run: -> + # We are loading packages in unordered mode, so we are fixing imports here, if needed. + Activity = Package.core.Activity unless Activity + Email = Package.core.Email unless Email + User = Package.core.User unless User + + fromTimestamp = @data.fromTimestamp + toTimestamp = new Date() + + JobsWorker.collection.update @_id, + $set: + 'data.toTimestamp': toTimestamp + + @processActivities Activity.documents.find( + timestamp: + $gte: fromTimestamp + $lt: toTimestamp + level: + $in: [Activity.LEVEL.USER, Activity.LEVEL.GENERAL] + , + transform: null + ).fetch() + + futureActivitiesExist = Activity.documents.exists + timestamp: + $gte: toTimestamp + level: + $in: [Activity.LEVEL.USER, Activity.LEVEL.GENERAL] + + if futureActivitiesExist + # ActivityEmailsJob is enqueued only if there is no existing job which would cover this timestamp. + new ActivityEmailsJob(fromTimestamp: toTimestamp).enqueue() + + processActivities: (activities) -> + # We are loading packages in unordered mode, so we are fixing imports here, if needed. + Activity = Package.core.Activity unless Activity + Email = Package.core.Email unless Email + User = Package.core.User unless User + + class LocalActivity extends Activity + @Meta + name: 'LocalActivity' + collection: null + + for activity in activities + LocalActivity.documents.insert activity + + css = fs.readFileSync [__meteor_bootstrap__.serverDir, '..', 'web.browser', 'merged-stylesheets.css'].join(pathModule.sep), + encoding: 'utf8' + + # TODO: Remove once this is fixed: https://github.com/Automattic/juice/issues/244 + css += """ + html { + font-size: 14px; + } + """ + + User.documents.find( + # TODO: We should query relevant and active users for activities in a better way, especially once we have groups. + roles: + $exists: true + $ne: [] + 'emails.verified': true + , + fields: + _id: 1 + emails: + $elemMatch: + verified: true + ).forEach (user, index, cursor) => + # TODO: Allow configuring which e-mail address is used for notifications. + address = user.emails?[0]?.address + return unless address + + userActivities = Activity.combineActivities LocalActivity.documents.find(Activity.personalizedActivityQuery(user._id)).fetch() + + return unless userActivities.length + + emailId = Random.id() + + # DOCTYPE cannot be a part of the template. + html = @_absoluteURLs '' + new ActivityEmailsComponent(userActivities, emailId).renderComponentToHTML() + + # Inline all CSS. + html = juice.inlineContent html, css + + Email.send + _id: emailId + from: Accounts.emailTemplates.from + to: address + subject: "[#{Accounts.emailTemplates.siteName}] Recent notifications" + # TODO + text: "" + html: html + headers: + Precedence: 'bulk' + + _absoluteURLs: (html) -> + $ = cheerio.load html, + # Normalize whitespace. + # TODO: Probably not necessary once: https://github.com/meteor/blaze/issues/88 + normalizeWhitespace: true + xmlMode: false + decodeEntities: true + + $.root().find('a[href]').each (index, element) => + $element = $(element) + $element.attr('href', url.resolve Meteor.absoluteUrl(), $element.attr('href')) + + $.root().find('img[src]').each (index, element) => + $element = $(element) + $element.attr('src', url.resolve Meteor.absoluteUrl(), $element.attr('src')) + + $.html() diff --git a/packages/jobs/email.html b/packages/jobs/email.html new file mode 100644 index 0000000..5232e19 --- /dev/null +++ b/packages/jobs/email.html @@ -0,0 +1,32 @@ + diff --git a/packages/jobs/package.js b/packages/jobs/package.js index 0833a4f..33e9367 100644 --- a/packages/jobs/package.js +++ b/packages/jobs/package.js @@ -3,34 +3,47 @@ Package.describe({ version: '0.1.0' }); +Npm.depends({ + 'juice': '3.0.1' +}); + Package.onUse(function (api) { api.versionsFrom('1.4.1'); // Core dependencies. api.use([ - 'coffeescript' + 'coffeescript', + 'http', + 'random', + 'accounts-password' ]); // 3rd party dependencies. api.use([ 'peerlibrary:assert@0.2.5', 'alanning:roles@1.2.15', - 'peerlibrary:classy-job@0.5.0' + 'peerlibrary:classy-job@0.6.1', + 'fermuch:cheerio@0.19.0' ]); // Internal dependencies. api.use([ + 'ui-components' ]); // Dependencies for jobs themselves, can be unordered. api.use([ 'voting', - 'core' + 'core', + 'peermind' ], {unordered: true}); api.export('ComputeTallyJob'); + api.export('ActivityEmailsJob'); api.addFiles([ - 'tally.coffee' + 'tally.coffee', + 'email.html', + 'email.coffee' ], 'server'); }); diff --git a/packages/peermind/activity/list.coffee b/packages/peermind/activity/list.coffee index e0b2627..ae37679 100644 --- a/packages/peermind/activity/list.coffee +++ b/packages/peermind/activity/list.coffee @@ -55,7 +55,10 @@ class Activity.ListItemComponent extends UIComponent @register 'Activity.ListItemComponent' mixins: -> - super.concat share.IsSeenMixin + if @isServer() + super + else + super.concat share.IsSeenMixin constructor: (kwargs) -> super @@ -142,6 +145,9 @@ class Activity.ListItemComponent extends UIComponent console.error "Missing an icon for activity type '#{type}'." null + isServer: -> + Meteor.isServer + class Activity.ListItemContainerComponent extends UIComponent @register 'Activity.ListItemContainerComponent' diff --git a/packages/peermind/activity/list.html b/packages/peermind/activity/list.html index c9cd138..dd7bcb6 100644 --- a/packages/peermind/activity/list.html +++ b/packages/peermind/activity/list.html @@ -87,7 +87,12 @@ {{/if}} {{> renderActivity}}

- {{icon}} {{fromNow timestamp}} + {{icon}} + {{#if isServer}} + {{formatDate timestamp DEFAULT_DATETIME_FORMAT}} + {{else}} + {{fromNow timestamp}} + {{/if}}

{{/Activity.ListItemContainerComponent}} diff --git a/packages/peermind/discussion/display-route.coffee b/packages/peermind/discussion/display-route.coffee new file mode 100644 index 0000000..ab7cb54 --- /dev/null +++ b/packages/peermind/discussion/display-route.coffee @@ -0,0 +1,10 @@ +FlowRouter.route '/discussion/:_id', + name: 'Discussion.display' + action: (params, queryParams) -> + BlazeLayout.render 'ColumnsLayoutComponent', + main: 'Discussion.DisplayComponent' + first: 'Comment.ListComponent' + second: 'Point.ListComponent' + third: 'Motion.ListComponent' + + # We set PageTitle after we get discussion title. diff --git a/packages/peermind/discussion/display.coffee b/packages/peermind/discussion/display.coffee index ca108bd..e599da0 100644 --- a/packages/peermind/discussion/display.coffee +++ b/packages/peermind/discussion/display.coffee @@ -145,14 +145,3 @@ class Discussion.FollowingDropdown extends UIComponent return @dialogOpened false - -FlowRouter.route '/discussion/:_id', - name: 'Discussion.display' - action: (params, queryParams) -> - BlazeLayout.render 'ColumnsLayoutComponent', - main: 'Discussion.DisplayComponent' - first: 'Comment.ListComponent' - second: 'Point.ListComponent' - third: 'Motion.ListComponent' - - # We set PageTitle after we get discussion title. diff --git a/packages/peermind/layout/header.html b/packages/peermind/layout/header.html index e8f9b73..cc97045 100644 --- a/packages/peermind/layout/header.html +++ b/packages/peermind/layout/header.html @@ -6,7 +6,7 @@ {{! TODO: Programmatically resolve the root URL. }} {{/if}}

{{title}}

diff --git a/packages/peermind/layout/header.styl b/packages/peermind/layout/header.styl index d0f0590..30c226d 100644 --- a/packages/peermind/layout/header.styl +++ b/packages/peermind/layout/header.styl @@ -12,9 +12,15 @@ nav .nav-wrapper &:hover background-color rgba(0, 0, 0, 0.1) + // Smaller logo is used in e-mail notifications. img - width $navbar-height - height $navbar-height + width $navbar-height-mobile + height $navbar-height-mobile + + @media $medium-and-up + img + width $navbar-height + height $navbar-height .not-large-screen .notifications-menu-button .button-collapse diff --git a/packages/peermind/meeting/display-route.coffee b/packages/peermind/meeting/display-route.coffee new file mode 100644 index 0000000..434fe13 --- /dev/null +++ b/packages/peermind/meeting/display-route.coffee @@ -0,0 +1,7 @@ +FlowRouter.route '/meeting/:_id', + name: 'Meeting.display' + action: (params, queryParams) -> + BlazeLayout.render 'MainLayoutComponent', + main: 'Meeting.DisplayComponent' + + # We set PageTitle after we get meeting title. diff --git a/packages/peermind/meeting/display.coffee b/packages/peermind/meeting/display.coffee index f6238b6..ff1fcb4 100644 --- a/packages/peermind/meeting/display.coffee +++ b/packages/peermind/meeting/display.coffee @@ -234,11 +234,3 @@ class Meeting.EditFormComponent extends UIComponent class Meeting.DisplayComponent.FixedButton extends UIComponent @register 'Meeting.DisplayComponent.FixedButton' - -FlowRouter.route '/meeting/:_id', - name: 'Meeting.display' - action: (params, queryParams) -> - BlazeLayout.render 'MainLayoutComponent', - main: 'Meeting.DisplayComponent' - - # We set PageTitle after we get meeting title. diff --git a/packages/peermind/package.js b/packages/peermind/package.js index 80be428..765236f 100644 --- a/packages/peermind/package.js +++ b/packages/peermind/package.js @@ -69,7 +69,13 @@ Package.onUse(function (api) { 'account/form.html', 'account/form.coffee', 'account/form.styl', - 'account/templates.coffee' + 'account/templates.coffee', + 'activity/list.html', + 'activity/list.coffee', + 'activity/list.styl', + 'meeting/display-route.coffee', + 'user/display-route.coffee', + 'discussion/display-route.coffee' ], ['client', 'server'], options); api.addFiles([ @@ -168,10 +174,7 @@ Package.onUse(function (api) { 'admin/accounts.coffee', 'user/display.html', 'user/display.coffee', - 'user/display.styl', - 'activity/list.html', - 'activity/list.coffee', - 'activity/list.styl' + 'user/display.styl' ], 'client', options); api.addAssets([ diff --git a/packages/peermind/user/display-route.coffee b/packages/peermind/user/display-route.coffee new file mode 100644 index 0000000..a094866 --- /dev/null +++ b/packages/peermind/user/display-route.coffee @@ -0,0 +1,7 @@ +FlowRouter.route '/user/:_id', + name: 'User.display' + action: (params, queryParams) -> + BlazeLayout.render 'MainLayoutComponent', + main: 'User.DisplayComponent' + + # We set PageTitle after we get user username. diff --git a/packages/peermind/user/display.coffee b/packages/peermind/user/display.coffee index 339a060..12b0efb 100644 --- a/packages/peermind/user/display.coffee +++ b/packages/peermind/user/display.coffee @@ -49,11 +49,3 @@ class User.DisplayComponent extends UIComponent # TODO: Should we populate the list with user's friends or something like this? contributeUsersForMention: -> [] - -FlowRouter.route '/user/:_id', - name: 'User.display' - action: (params, queryParams) -> - BlazeLayout.render 'MainLayoutComponent', - main: 'User.DisplayComponent' - - # We set PageTitle after we get user username. From e740e654a0fa168d9d4266ff24e9191bf4fd3d68 Mon Sep 17 00:00:00 2001 From: Mitar Date: Sun, 13 Nov 2016 04:29:49 -0800 Subject: [PATCH 02/49] Remove icons from e-mails. --- packages/jobs/email.html | 3 --- packages/peermind/activity/list.coffee | 7 +++++-- packages/peermind/activity/list.html | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/jobs/email.html b/packages/jobs/email.html index 5232e19..50648bf 100644 --- a/packages/jobs/email.html +++ b/packages/jobs/email.html @@ -1,8 +1,5 @@