summaryrefslogtreecommitdiff
path: root/src/client/pages/user-ap-info.vue
blob: c08a3525711233b626cb8c1b948626470c7d3648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<FormBase>
	<FormSuspense :p="apPromiseFactory" v-slot="{ result: ap }">
		<FormGroup>
			<template #label>ActivityPub</template>
			<FormKeyValueView>
				<template #key>Type</template>
				<template #value><span class="_monospace">{{ ap.type }}</span></template>
			</FormKeyValueView>
			<FormKeyValueView>
				<template #key>URI</template>
				<template #value><span class="_monospace">{{ ap.id }}</span></template>
			</FormKeyValueView>
			<FormKeyValueView>
				<template #key>URL</template>
				<template #value><span class="_monospace">{{ ap.url }}</span></template>
			</FormKeyValueView>
			<FormGroup>
				<FormKeyValueView>
					<template #key>Inbox</template>
					<template #value><span class="_monospace">{{ ap.inbox }}</span></template>
				</FormKeyValueView>
				<FormKeyValueView>
					<template #key>Shared Inbox</template>
					<template #value><span class="_monospace">{{ ap.sharedInbox || ap.endpoints.sharedInbox }}</span></template>
				</FormKeyValueView>
				<FormKeyValueView>
					<template #key>Outbox</template>
					<template #value><span class="_monospace">{{ ap.outbox }}</span></template>
				</FormKeyValueView>
			</FormGroup>
			<FormTextarea readonly tall code pre :value="ap.publicKey.publicKeyPem">
				<span>Public Key</span>
			</FormTextarea>
			<FormKeyValueView>
				<template #key>Discoverable</template>
				<template #value>{{ ap.discoverable ? $ts.yes : $ts.no }}</template>
			</FormKeyValueView>
			<FormKeyValueView>
				<template #key>ManuallyApprovesFollowers</template>
				<template #value>{{ ap.manuallyApprovesFollowers ? $ts.yes : $ts.no }}</template>
			</FormKeyValueView>
			<FormObjectView tall :value="ap">
				<span>Raw</span>
			</FormObjectView>
			<FormGroup>
				<FormLink :to="`https://${user.host}/.well-known/webfinger?resource=acct:${user.username}`" external>WebFinger</FormLink>
			</FormGroup>
			<FormLink v-if="user.host" :to="`/instance-info/${user.host}`">{{ $ts.instanceInfo }}<template #suffix>{{ user.host }}</template></FormLink>
			<FormKeyValueView v-else>
				<template #key>{{ $ts.instanceInfo }}</template>
				<template #value>(Local user)</template>
			</FormKeyValueView>
		</FormGroup>
	</FormSuspense>
</FormBase>
</template>

<script lang="ts">
import { defineAsyncComponent, defineComponent } from 'vue';
import FormObjectView from '@client/components/form/object-view.vue';
import FormTextarea from '@client/components/form/textarea.vue';
import FormLink from '@client/components/form/link.vue';
import FormBase from '@client/components/form/base.vue';
import FormGroup from '@client/components/form/group.vue';
import FormButton from '@client/components/form/button.vue';
import FormKeyValueView from '@client/components/form/key-value-view.vue';
import FormSuspense from '@client/components/form/suspense.vue';
import * as os from '@client/os';
import number from '@client/filters/number';
import bytes from '@client/filters/bytes';
import * as symbols from '@client/symbols';
import { url } from '@client/config';

export default defineComponent({
	components: {
		FormBase,
		FormTextarea,
		FormObjectView,
		FormButton,
		FormLink,
		FormGroup,
		FormKeyValueView,
		FormSuspense,
	},

	props: {
		userId: {
			type: String,
			required: true
		}
	},

	data() {
		return {
			[symbols.PAGE_INFO]: {
				title: this.$ts.userInfo,
				icon: 'fas fa-info-circle'
			},
			user: null,
			apPromiseFactory: null,
		}
	},

	mounted() {
		this.fetch();
	},

	methods: {
		number,
		bytes,

		async fetch() {
			this.user = await os.api('users/show', {
				userId: this.userId
			});

			this.apPromiseFactory = () => os.api('ap/get', {
				uri: this.user.uri || `${url}/users/${this.user.id}`
			});
		}
	}
});
</script>