Permalink
Browse files

Drop support for Pushbullet

I no longer use this service, and it doesn't appear to be maintained.
  • Loading branch information...
lovett committed Oct 3, 2018
1 parent 9e9decc commit 170bf33693d90750ffa53a3bc74328b567191713
@@ -108,25 +108,25 @@ migrate: dummy
sqlite3 notifier.sqlite < migrations/01-message-drop-deliveredat.sql

onemessage: dummy
clients/send-notification -s $(NOTIFIER_DEV) -t "Single test message" -e "5 hours" -p 0 -u "http://example.com" -l "onemessage"
clients/send-notification -s $(NOTIFIER_DEV) -t "Single test message" -e "5 hours" -u "http://example.com" -l "onemessage"

badgemessage: dummy
clients/send-notification -s $(NOTIFIER_DEV) -t "Badged message test" -g sysup -i "test.svg" -e "5 hours" -p 0 -u "http://example.com" -l "badged"
clients/send-notification -s $(NOTIFIER_DEV) -t "Badged message test" -g sysup -i "test.svg" -e "5 hours" -u "http://example.com" -l "badged"

multimessage: dummy
clients/send-notification -s $(NOTIFIER_DEV) -t "email group test message" -g email -b "Message 1" -p 0 -l "multi-email"
clients/send-notification -s $(NOTIFIER_DEV) -t "phone group test message" -g phone -b "Message 2" -p 0 -l "multi-phone"
clients/send-notification -s $(NOTIFIER_DEV) -t "web group test message" -g web -b "Message 3" -p 0 -l "multi-web"
clients/send-notification -s $(NOTIFIER_DEV) -t "reminder group test message" -g reminder -b "Message 4" -p 0 -l "multi-reminder"
clients/send-notification -s $(NOTIFIER_DEV) -t "calendar group test message" -g calendar -b "Message 5" -p 0 -l "multi-calendar"
clients/send-notification -s $(NOTIFIER_DEV) -t "sysdown group test message" -g sysdown -b "Message 6" -p 0 -l "multi-sysdown"
clients/send-notification -s $(NOTIFIER_DEV) -t "sysdown group test message" -g sysdown -b "Message 7" -p 0 -l "multi-sysdown"
clients/send-notification -s $(NOTIFIER_DEV) -t "sysup group test message" -g sysup -b "Message 8" -p 0 -l "multi-sysup"
clients/send-notification -s $(NOTIFIER_DEV) -t "chore group test message" -g chore -b "Message 9" -p 0 -l "multi-chore"
clients/send-notification -s $(NOTIFIER_DEV) -t "education group test message" -g education -b "Message 10" -p 0 -l "multi-education"
clients/send-notification -s $(NOTIFIER_DEV) -t "computer group test message" -g computer -b "Message 11" -p 0 -l "multi-computer"
clients/send-notification -s $(NOTIFIER_DEV) -t "financial group test message" -g financial -b "Message 12" -p 0 -l "multi-financial"
clients/send-notification -s $(NOTIFIER_DEV) -t "custom badge test message" -b "Message 13" -p 0 -l "mult-badge" -i "test.svg"
clients/send-notification -s $(NOTIFIER_DEV) -t "email group test message" -g email -b "Message 1" -l "multi-email"
clients/send-notification -s $(NOTIFIER_DEV) -t "phone group test message" -g phone -b "Message 2" -l "multi-phone"
clients/send-notification -s $(NOTIFIER_DEV) -t "web group test message" -g web -b "Message 3" -l "multi-web"
clients/send-notification -s $(NOTIFIER_DEV) -t "reminder group test message" -g reminder -b "Message 4" -l "multi-reminder"
clients/send-notification -s $(NOTIFIER_DEV) -t "calendar group test message" -g calendar -b "Message 5" -l "multi-calendar"
clients/send-notification -s $(NOTIFIER_DEV) -t "sysdown group test message" -g sysdown -b "Message 6" -l "multi-sysdown"
clients/send-notification -s $(NOTIFIER_DEV) -t "sysdown group test message" -g sysdown -b "Message 7" -l "multi-sysdown"
clients/send-notification -s $(NOTIFIER_DEV) -t "sysup group test message" -g sysup -b "Message 8" -l "multi-sysup"
clients/send-notification -s $(NOTIFIER_DEV) -t "chore group test message" -g chore -b "Message 9" -l "multi-chore"
clients/send-notification -s $(NOTIFIER_DEV) -t "education group test message" -g education -b "Message 10" -l "multi-education"
clients/send-notification -s $(NOTIFIER_DEV) -t "computer group test message" -g computer -b "Message 11" -l "multi-computer"
clients/send-notification -s $(NOTIFIER_DEV) -t "financial group test message" -g financial -b "Message 12" -l "multi-financial"
clients/send-notification -s $(NOTIFIER_DEV) -t "custom badge test message" -b "Message 13" -l "mult-badge" -i "test.svg"

retract: dummy
clients/send-notification -s $(NOTIFIER_DEV) -c -l test
@@ -5,6 +5,4 @@
"NOTIFIER_HTTP_IP": "0.0.0.0",
"NOTIFIER_DEFAULT_USER": "{{ default_user }}",
"NOTIFIER_DEFAULT_PASSWORD": "{{ default_password }}",
"NOTIFIER_PUSHBULLET_CLIENT_ID": "{{ pushbullet_client_id }}",
"NOTIFIER_PUSHBULLET_CLIENT_SECRET": "{{ pushbullet_client_secret }}"
}
@@ -2,9 +2,6 @@
<li ng-hide="state.bn == 'unavailable'">
<a tabindex="0" ng-click="enable('bn')" ng-href="">{{state.bn|symbolize}} Browser notifications</a>
</li>
<li>
<a tabindex="0" ng-click="toggle('pushbullet')" ng-href="">{{state.pushbullet|symbolize}} Pushbullet</a>
</li>
<li>
<a tabindex="0" ng-click="enable('webhook')" ng-href="">{{ state.webhook|symbolize}} Web hook</a>
</li>
@@ -26,7 +26,7 @@ ${0##*/} -a
To send a message after setting up authentication:
${0##*/} -s SERVER -t TITLE -g GROUP -b BODY -u URL
-p PUSHBULLET_ID -e EXPIRATION
-e EXPIRATION
EOF
}
@@ -113,7 +113,6 @@ GROUP=""
BODY=""
BADGE=""
URL=""
PUSHBULLET_ID=""
LOCAL_ID=""
SERVER=${NOTIFIER_SERVER:-}
ENDPOINT="message"
@@ -143,9 +142,6 @@ while getopts "ahcVp:s:t:g:b:u:l:e:i:" opt; do
u)
URL="$OPTARG"
;;
p)
PUSHBULLET_ID="$OPTARG"
;;
l)
LOCAL_ID="$OPTARG"
;;
@@ -187,7 +183,6 @@ until [ "$RETRIES" -lt 1 ]; do
--data-urlencode "group=$GROUP" \
--data-urlencode "body=$BODY" \
--data-urlencode "url=$URL" \
--data-urlencode "pushbulletId=$PUSHBULLET_ID" \
--data-urlencode "badge=$BADGE" \
--data-urlencode "localId=$LOCAL_ID" \
--data-urlencode "expiresAt=$EXPIRATION" \
@@ -0,0 +1,5 @@
BEGIN TRANSACTION;

ALTER TABLE `Messages` DROP COLUMN `pushbulletId`;

COMMIT;
@@ -3,81 +3,13 @@ import * as needle from 'needle';
import getServiceTokens from '../helpers/service-tokens';
import { Message, MessageInstance, TokenInstance, User } from '../types/server';

enum PushbulletType {
note = 'note',
link = 'link',
}


interface PushbulletParams {
body: string;
guid: string;
title: string;
type: PushbulletType;
url?: string;
}


function publishServerEvent(app: express.Application, _: User, message: Message) {
for (const id of Object.keys(app.locals.pushClients)) {
const res = app.locals.pushClients[id];
res.write(`event: message\ndata: ${JSON.stringify(message)}\n\n`);
}
}

function publishPushbullet(app: express.Application, _: User, message: Message, tokenValue: string) {
let params;

if (message.hasOwnProperty('retracted')) {
app.locals.Message.find({
attributes: ['pushbulletId'],
where: { publicId: message.retracted },
}).then((foundMessage: MessageInstance) => {
if (foundMessage.pushbulletId === '0') {
return;
}

needle.delete('https://api.pushbullet.com/v2/pushes/' + foundMessage.pushbulletId, null, {
password: '',
username: tokenValue,
});
});
return;
}

if (message.pushbulletId === '0') {
return;
}

params = <PushbulletParams>{
body: message.body,
guid: message.publicId,
title: message.title,
type: PushbulletType.note,
};

if (message.url) {
params.type = PushbulletType.link;
params.url = message.url;
}

needle.post('https://api.pushbullet.com/v2/pushes', params, {
password: '',
username: tokenValue,
}, (err: Error, res) => {
if (err || res.body.error) {
return false;
}

app.locals.Message.update(
{ pushbulletId: res.body.iden },
{ where: { publicId: message.publicId } },
);

return true;
});
}

function publishWebhook(_: User, message: Message, tokenValue: string) {
delete message.UserId;
delete message.id;
@@ -118,10 +50,6 @@ export default (app: express.Application, user: User, message: MessageInstance|n
getServiceTokens(app, user, (tokens: TokenInstance[]) => {

for (const token of tokens) {
if (token.key === 'pushbullet') {
publishPushbullet(app, user, messageValues, token.value);
}

if (token.key === 'webhook') {
publishWebhook(user, messageValues, token.value);
}
@@ -75,11 +75,6 @@ export default function(sequelize: Sequelize.Sequelize, badgeBaseUrl: string) {
type: Sequelize.UUID,
},

pushbulletId: {
allowNull: true,
type: Sequelize.STRING(255),
},

source: {
allowNull: true,
set(this: MessageInstance, value: string) {

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -31,8 +31,6 @@ import messageIndex from './routes/message/index';
import messageUnclear from './routes/message/unclear';
import publishMessage from './helpers/publish-message';
import push from './routes/push';
import pushbulletFinish from './routes/pushbullet/finish';
import pushbulletStart from './routes/pushbullet/start';
import revoke from './routes/revoke';
import robots from './routes/robots';
import security from './middleware/security';
@@ -83,8 +81,6 @@ nconf.defaults({
NOTIFIER_PASSWORD_HASH_KEYLENGTH: 64,
NOTIFIER_PASSWORD_HASH_RANDBYTES: 64,
NOTIFIER_PUBLIC_DIR: path.resolve('./build/public'),
NOTIFIER_PUSHBULLET_CLIENT_ID: undefined,
NOTIFIER_PUSHBULLET_CLIENT_SECRET: undefined,
NOTIFIER_SSL_CERT: undefined,
NOTIFIER_SSL_KEY: undefined,
});
@@ -188,10 +184,6 @@ router.use('/services', app.locals.protected, services);

router.use('/revoke', app.locals.protected, revoke);

router.use('/authorize/pushbullet/start', app.locals.protected, pushbulletStart);

router.use('/authorize/pushbullet/finish', pushbulletFinish);

router.use('/auth', passport.authenticate('local', { session: false }), auth);

router.use('/message', app.locals.protected, messageIndex);
@@ -14,7 +14,6 @@ interface Message extends IndexSignature {
publicId?: string;
retracted?: string;
localId?: string;
pushbulletId?: string;
UserId?: number;

}
@@ -26,7 +25,6 @@ interface MessageInstance extends Sequelize.Instance<Message> {
expiresAt?: Date;
localId?: string;
publicId: string;
pushbulletId?: string;
purgeServiceToken(service: string, callback: (affectedRows: number) => void): void;
setUser(user: User): Promise<MessageInstance>;
title: string;

0 comments on commit 170bf33

Please sign in to comment.