Parse mastodon favorites.

This commit is contained in:
Roger Braun 2016-11-27 18:54:17 +01:00
parent 4228f49e7b
commit ff93d1edee
2 changed files with 18 additions and 3 deletions

View file

@ -62,7 +62,7 @@ export const updateTimestampsInStatuses = (statuses) => {
})
}
const statusType = (status) => {
export const statusType = (status) => {
if (status.is_post_verb) {
return 'status'
}
@ -71,7 +71,7 @@ const statusType = (status) => {
return 'retweet'
}
if (typeof status.uri === 'string' && status.uri.match(/fave/)) {
if (typeof status.uri === 'string' && status.uri.match(/(fave|objectType=Favourite)/)) {
return 'favorite'
}

View file

@ -1,5 +1,5 @@
import { cloneDeep } from 'lodash'
import { defaultState, mutations, findMaxId, prepareStatus } from '../../../../src/modules/statuses.js'
import { defaultState, mutations, findMaxId, prepareStatus, statusType } from '../../../../src/modules/statuses.js'
const makeMockStatus = ({id, text, is_post_verb = true}) => {
return {
@ -13,6 +13,21 @@ const makeMockStatus = ({id, text, is_post_verb = true}) => {
}
}
describe('Statuses.statusType', () => {
it('identifies favorites', () => {
const fav = {
uri: 'tag:soykaf.com,2016-08-21:fave:2558:note:339495:2016-08-21T16:54:04+00:00'
}
const mastoFav = {
uri: 'tag:mastodon.social,2016-11-27:objectId=73903:objectType=Favourite'
}
expect(statusType(fav)).to.eql('favorite')
expect(statusType(mastoFav)).to.eql('favorite')
})
})
describe('Statuses.prepareStatus', () => {
it('sets nsfw for statuses with the #nsfw tag', () => {
const safe = makeMockStatus({id: 1, text: 'Hello oniichan'})