2019-10-12 18:30:33 +00:00
|
|
|
<template>
|
|
|
|
<div class="w3-card">
|
2019-10-12 19:20:19 +00:00
|
|
|
<div class="actor">
|
|
|
|
<img crossorigin="anonymous" :src="actorIconUrl">
|
|
|
|
<label>
|
|
|
|
{{ actor.preferredUsername }}
|
|
|
|
<span class="muted">@{{ actorHost }}</span>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<p v-html="post.content"></p>
|
2019-10-12 18:30:33 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
activity: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2019-10-12 19:20:19 +00:00
|
|
|
post: {},
|
|
|
|
actor: {},
|
|
|
|
isError: false,
|
2019-10-12 18:30:33 +00:00
|
|
|
}
|
|
|
|
},
|
2019-10-12 19:20:19 +00:00
|
|
|
computed: {
|
|
|
|
actorIconUrl() {
|
|
|
|
return this.actor.icon && this.actor.icon.url
|
|
|
|
},
|
|
|
|
actorHost() {
|
|
|
|
try {
|
|
|
|
const id = new URL(this.actor.id)
|
|
|
|
return id.host
|
|
|
|
} catch (ignore) {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
resolveObject(idOrObject) {
|
|
|
|
if (typeof idOrObject !== 'string') {
|
|
|
|
return new Promise((resolve) => resolve(idOrObject))
|
|
|
|
}
|
|
|
|
return window.fetch(`/o/${encodeURIComponent(idOrObject)}`, {
|
2019-10-12 18:30:33 +00:00
|
|
|
method: 'get',
|
|
|
|
headers: {
|
|
|
|
accept: 'application/activity+json'
|
|
|
|
}
|
2019-10-12 19:20:19 +00:00
|
|
|
})
|
|
|
|
.then(res => res.json())
|
2019-10-12 18:30:33 +00:00
|
|
|
.catch(err => {
|
2019-10-12 19:20:19 +00:00
|
|
|
this.isError = true
|
|
|
|
console.log(err.message)
|
2019-10-12 18:30:33 +00:00
|
|
|
})
|
|
|
|
}
|
2019-10-12 19:20:19 +00:00
|
|
|
},
|
|
|
|
created () {
|
|
|
|
this.resolveObject(this.activity.object)
|
|
|
|
.then(object => {
|
|
|
|
this.post = object
|
|
|
|
return this.resolveObject(this.post.attributedTo)
|
|
|
|
})
|
|
|
|
.then(actor => { this.actor = actor })
|
2019-10-12 18:30:33 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-12 19:20:19 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.actor img {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
|
|
|
.actor label {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
.actor label .muted {
|
|
|
|
font-weight: normal;
|
|
|
|
color: gray;
|
|
|
|
}
|
|
|
|
</style>
|