Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save sender email for messages read/starred/sent/deleted #2625

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@nextcloud/auth": "^1.2.1",
"@nextcloud/axios": "^1.3.1",
"@nextcloud/dialogs": "^1.0.0",
"@nextcloud/event-bus": "^1.1.2",
"@nextcloud/files": "^1.0.0",
"@nextcloud/initial-state": "^1.1.0",
"@nextcloud/l10n": "^1.0.1",
Expand Down
7 changes: 7 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
</template>

<script>
import {subscribe} from '@nextcloud/event-bus'

import logger from './logger'
import {matchError} from './errors/match'
import MailboxLockedError from './errors/MailboxLockedError'
import {collect} from "./service/ContactsInteraction";

export default {
name: 'App',
mounted() {
this.sync()
this.collectInteractions()
},
methods: {
sync() {
Expand All @@ -56,6 +60,9 @@ export default {
}
}, 30 * 1000)
},
collectInteractions() {
subscribe('mail:interaction', collect)
}
},
}
</script>
6 changes: 5 additions & 1 deletion src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ import {htmlToText, textToSimpleHtml} from '../util/HtmlHelper'
import Loading from './Loading'
import logger from '../logger'
import TextEditor from './TextEditor'
import {emit} from '@nextcloud/event-bus'

const debouncedSearch = debouncePromise(findRecipient, 500)

Expand Down Expand Up @@ -421,7 +422,10 @@ export default {
.then(this.getMessageData())
.then(data => this.send(data))
.then(() => logger.info('message sent'))
.then(() => (this.state = STATES.FINISHED))
.then(() => {
emit('mail:interaction', {type: 'message-sent', recipient: this.selectedUser.user})
this.state = STATES.FINISHED
})
.catch(error => {
logger.error('could not send message', {error})
if (error && error.toString) {
Expand Down
12 changes: 10 additions & 2 deletions src/components/Envelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import Moment from './Moment'

import Avatar from './Avatar'
import {calculateAccountColor} from '../util/AccountColor'
import {emit} from '@nextcloud/event-bus'

export default {
name: 'Envelope',
Expand Down Expand Up @@ -125,8 +126,15 @@ export default {
},
},
methods: {
onToggleFlagged() {
this.$store.dispatch('toggleEnvelopeFlagged', this.data)
async onToggleFlagged() {
await this.$store.dispatch('toggleEnvelopeFlagged', this.data)

if (this.data.flags.flagged) {
emit('mail:interaction', {
type: 'message-starred',
sender: this.data.from,
})
}
},
onToggleSeen() {
this.$store.dispatch('toggleEnvelopeSeen', this.data)
Expand Down
15 changes: 13 additions & 2 deletions src/components/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import MessagePlainTextBody from './MessagePlainTextBody'
import Loading from './Loading'
import Logger from '../logger'
import MessageAttachments from './MessageAttachments'
import {emit} from '@nextcloud/event-bus'

export default {
name: 'Message',
Expand Down Expand Up @@ -231,7 +232,12 @@ export default {
})
},
onToggleSeen() {
this.$store.dispatch('toggleEnvelopeSeen', this.envelope)
this.$store.dispatch('toggleEnvelopeSeen', this.envelope).then(() => {
emit('mail:interaction', {
type: 'message-read',
recipient: this.selectedUser.user,
})
})
},
onDelete(e) {
// Don't try to navigate to the deleted message
Expand All @@ -251,7 +257,12 @@ export default {
}

this.$emit('delete', this.envelope)
this.$store.dispatch('deleteMessage', this.envelope)
this.$store.dispatch('deleteMessage', this.envelope).then(() => {
emit('mail:interaction', {
type: 'message-delete',
recipient: this.selectedUser.user,
})
})

if (!next) {
Logger.debug('no next/previous envelope, not navigating')
Expand Down
26 changes: 26 additions & 0 deletions src/service/ContactsInteraction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import logger from '../logger'

export const collect = data => {
logger.info('collecting user interaction data', {data})
}