mastodon bot control

This commit is contained in:
lesion 2019-06-26 17:11:37 +02:00
parent f34e32f065
commit b5ddaabaf7
2 changed files with 21 additions and 13 deletions

View file

@ -44,13 +44,13 @@
strong {{$t('common.related')}} -
a(:href='`https://${settings.mastodon_instance}/web/statuses/${event.activitypub_id}`') {{$t('common.add')}}
.card-header(v-for='comment in event.comments' :key='comment.id')
img.avatar(:src='comment.data.last_status.account.avatar')
strong {{comment.author}}
//- a.float-right(:href='comment.data.last_status.url')
a.float-right(:href='`https://${settings.mastodon_instance}/web/statuses/${comment.data.last_status.id}`')
small {{comment.data.last_status.created_at|datetime}}
div.mt-1(v-html='comment_filter(comment.data.last_status.content)')
img(v-for='img in comment.data.last_status.media_attachments' :src='img.url')
img.avatar(:src='comment.data.account.avatar')
strong {{comment.data.account.display_name}} {{comment.data.account.username}}
//- a.float-right(:href='comment.data.url')
a.float-right(:href='`https://${settings.mastodon_instance}/web/statuses/${comment.data.id}`')
small {{comment.data.created_at|datetime}}
div.mt-1(v-html='comment_filter(comment.data.content)')
img(v-for='img in comment.data.media_attachments' :src='img.url')
</template>
<script>
@ -193,7 +193,7 @@ export default {
}
img {
width: 100%;
max-width: 100%;
max-height: 89vh;
object-fit: contain;
}

View file

@ -57,12 +57,20 @@ ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : ev
// TOFIX: enable message deletion
async message(msg) {
const type = msg.event
const replyid = msg.data.in_reply_to_id
if (!replyid) return
let event = await Event.findOne({ where: { activitypub_id: replyid } })
if (type === 'delete') {
const activitypub_id = msg.data
const event = await Comment.findOne({ where: { activitypub_id } })
if (event) await event.destroy()
return
}
const activitypub_id = msg.data.in_reply_to_id
if (!activitypub_id) return
let event = await Event.findOne({ where: { activitypub_id } })
if (!event) {
// check for comment..
const comment = await Comment.findOne( { include: [Event], where: { activitypub_id: replyid }})
const comment = await Comment.findOne( { include: [Event], where: { activitypub_id }})
if (!comment) return
event = comment.event
}
@ -76,6 +84,6 @@ ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : ev
console.log('error ', err)
}
}
// botController.initialize()
setTimeout(botController.initialize, 5000)
module.exports = botController