mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-24 06:50:22 +08:00
dev: update referral and share notifs
This commit is contained in:
parent
0fa3be9d43
commit
36ca7f63aa
@ -132,21 +132,22 @@ If this was not you, please contact support@puter.com immediately.
|
||||
`
|
||||
},
|
||||
// TODO: revise email contents
|
||||
'share_existing_user': {
|
||||
'share_by_username': {
|
||||
subject: 'Puter share from {{susername}}',
|
||||
html: `
|
||||
html: /*html*/`
|
||||
<p>Hi there {{rusername}},</p>
|
||||
<p>{{link}}</p>
|
||||
<p>You've received a share from {{susername}} on Puter.</p>
|
||||
<p>Go to puter.com to check it out.</p>
|
||||
<p>Sincerely,</p>
|
||||
<p>Puter</p>
|
||||
`
|
||||
},
|
||||
'share_by_email': {
|
||||
subject: 'share by email',
|
||||
html: `
|
||||
html: /*html*/`
|
||||
<p>Hi there,</p>
|
||||
<p>You've received a share from {{sender_name}} on Puter:</p>
|
||||
<p>{{link}}</p>
|
||||
<p><a href="{{link}}">{{link}}</a></p>
|
||||
<p>Sincerely,</p>
|
||||
<p>Puter</p>
|
||||
`
|
||||
|
@ -29,6 +29,10 @@ const UsernameNotifSelector = username => async (self) => {
|
||||
return [user.id];
|
||||
};
|
||||
|
||||
const UserIDNotifSelector = user_id => async (self) => {
|
||||
return [user_id];
|
||||
};
|
||||
|
||||
class NotificationService extends BaseService {
|
||||
static MODULES = {
|
||||
uuidv4: require('uuid').v4,
|
||||
@ -214,4 +218,5 @@ class NotificationService extends BaseService {
|
||||
module.exports = {
|
||||
NotificationService,
|
||||
UsernameNotifSelector,
|
||||
UserIDNotifSelector,
|
||||
};
|
||||
|
@ -22,6 +22,7 @@ const { Context } = require('../util/context');
|
||||
const { get_user } = require('../helpers');
|
||||
const { DB_WRITE } = require('./database/consts');
|
||||
const BaseService = require('./BaseService');
|
||||
const { UsernameNotifSelector, UserIDNotifSelector } = require('./NotificationService');
|
||||
|
||||
class ReferralCodeService extends BaseService {
|
||||
_construct () {
|
||||
@ -117,7 +118,20 @@ class ReferralCodeService extends BaseService {
|
||||
const svc_email = Context.get('services').get('email');
|
||||
await svc_email.send_email (referred_by, 'new-referral', {
|
||||
storage_increase: this.STORAGE_INCREASE_STRING
|
||||
})
|
||||
});
|
||||
|
||||
const svc_notification = Context.get('services').get('notification');
|
||||
svc_notification.notify(UserIDNotifSelector(referred_by.id), {
|
||||
source: 'referral',
|
||||
icon: 'c-check.svg',
|
||||
text: `You have referred user ${user.username} and ` +
|
||||
`have received ${this.STORAGE_INCREASE_STRING} of storage.`,
|
||||
template: 'referral',
|
||||
fields: {
|
||||
storage_increase: this.STORAGE_INCREASE_STRING,
|
||||
referred_username: user.username
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,6 +485,7 @@ module.exports = new Sequence([
|
||||
|
||||
const svc_permission = a.iget('services').get('permission');
|
||||
const svc_notification = a.iget('services').get('notification');
|
||||
const svc_email = a.iget('services').get('email');
|
||||
|
||||
const actor = a.get('actor');
|
||||
|
||||
@ -541,6 +542,18 @@ module.exports = new Sequence([
|
||||
(files.length === 1 ? 'file' : 'files') + ' ' +
|
||||
'with you.',
|
||||
});
|
||||
|
||||
|
||||
// Working on notifications
|
||||
// Email should have a link to a shared file, right?
|
||||
// .. how do I make those URLs? (gui feature)
|
||||
await svc_email.send_email({
|
||||
email: recipient_item.user.email,
|
||||
}, 'share_by_username', {
|
||||
// link: // TODO: create a link to the shared file
|
||||
susername: actor.type.user.username,
|
||||
rusername: username,
|
||||
});
|
||||
|
||||
result.recipients[recipient_item.i] =
|
||||
{ $: 'api:status-report', status: 'success' };
|
||||
|
Loading…
Reference in New Issue
Block a user