@things-factory/gallery 10.1.248 → 10.1.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/bootstrap.d.ts +2 -0
- package/dist-client/bootstrap.js +26 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/components/gallery-forms.d.ts +31 -0
- package/dist-client/components/gallery-forms.js +223 -0
- package/dist-client/components/gallery-forms.js.map +1 -0
- package/dist-client/components/gallery-saver-setting-let.d.ts +11 -0
- package/dist-client/components/gallery-saver-setting-let.js +81 -0
- package/dist-client/components/gallery-saver-setting-let.js.map +1 -0
- package/dist-client/components/gallery-show.d.ts +46 -0
- package/dist-client/components/gallery-show.js +316 -0
- package/dist-client/components/gallery-show.js.map +1 -0
- package/dist-client/components/gallery-uploader.d.ts +57 -0
- package/dist-client/components/gallery-uploader.js +624 -0
- package/dist-client/components/gallery-uploader.js.map +1 -0
- package/dist-client/components/gallery-viewer.d.ts +30 -0
- package/dist-client/components/gallery-viewer.js +429 -0
- package/dist-client/components/gallery-viewer.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/gallery-page.d.ts +54 -0
- package/dist-client/pages/gallery-page.js +590 -0
- package/dist-client/pages/gallery-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +9 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-client/utils/gallery-api.d.ts +99 -0
- package/dist-client/utils/gallery-api.js +46 -0
- package/dist-client/utils/gallery-api.js.map +1 -0
- package/dist-client/utils/gallery-badge.d.ts +4 -0
- package/dist-client/utils/gallery-badge.js +45 -0
- package/dist-client/utils/gallery-badge.js.map +1 -0
- package/dist-client/utils/gallery-saver.d.ts +6 -0
- package/dist-client/utils/gallery-saver.js +69 -0
- package/dist-client/utils/gallery-saver.js.map +1 -0
- package/dist-client/utils/gallery-words.d.ts +7 -0
- package/dist-client/utils/gallery-words.js +20 -0
- package/dist-client/utils/gallery-words.js.map +1 -0
- package/dist-client/utils/photo-prep.d.ts +10 -0
- package/dist-client/utils/photo-prep.js +102 -0
- package/dist-client/utils/photo-prep.js.map +1 -0
- package/dist-server/attachment-reader.d.ts +1 -0
- package/dist-server/attachment-reader.js +13 -0
- package/dist-server/attachment-reader.js.map +1 -0
- package/dist-server/index.d.ts +1 -0
- package/dist-server/index.js +11 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/role-tasks.d.ts +2 -0
- package/dist-server/role-tasks.js +15 -0
- package/dist-server/role-tasks.js.map +1 -0
- package/dist-server/service/gallery/gallery-resolver.d.ts +29 -0
- package/dist-server/service/gallery/gallery-resolver.js +613 -0
- package/dist-server/service/gallery/gallery-resolver.js.map +1 -0
- package/dist-server/service/gallery/gallery-rules.d.ts +90 -0
- package/dist-server/service/gallery/gallery-rules.js +182 -0
- package/dist-server/service/gallery/gallery-rules.js.map +1 -0
- package/dist-server/service/gallery/gallery-service.d.ts +37 -0
- package/dist-server/service/gallery/gallery-service.js +234 -0
- package/dist-server/service/gallery/gallery-service.js.map +1 -0
- package/dist-server/service/gallery/gallery-types.d.ts +65 -0
- package/dist-server/service/gallery/gallery-types.js +239 -0
- package/dist-server/service/gallery/gallery-types.js.map +1 -0
- package/dist-server/service/gallery/gallery.d.ts +84 -0
- package/dist-server/service/gallery/gallery.js +335 -0
- package/dist-server/service/gallery/gallery.js.map +1 -0
- package/dist-server/service/gallery/index.d.ts +4 -0
- package/dist-server/service/gallery/index.js +8 -0
- package/dist-server/service/gallery/index.js.map +1 -0
- package/dist-server/service/index.d.ts +7 -0
- package/dist-server/service/index.js +23 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GalleryResolver = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const typeorm_1 = require("typeorm");
|
|
8
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
9
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
10
|
+
const calendar_1 = require("@things-factory/calendar");
|
|
11
|
+
const shell_1 = require("@things-factory/shell");
|
|
12
|
+
const gallery_1 = require("./gallery");
|
|
13
|
+
const gallery_rules_1 = require("./gallery-rules");
|
|
14
|
+
const gallery_service_1 = require("./gallery-service");
|
|
15
|
+
const gallery_types_1 = require("./gallery-types");
|
|
16
|
+
const MODERATE = '@privilege(category: "gallery", privilege: "mutation", domainOwnerGranted: true)';
|
|
17
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
18
|
+
/* A person who never opened the gallery hears of the last week's posts. */
|
|
19
|
+
const FIRST_LOOK = 7 * DAY;
|
|
20
|
+
/** A refusal said in the reader's words, with a code the screen may read. */
|
|
21
|
+
function refuse(context, code, fallback) {
|
|
22
|
+
const message = context.t ? String(context.t(`gallery.refusal.${code}`, { defaultValue: fallback })) : fallback;
|
|
23
|
+
const error = new Error(message);
|
|
24
|
+
error.extensions = { code: `gallery.${code}` };
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
const NOT_FOUND = 'there is no such post.';
|
|
28
|
+
async function visibleOrRefuse(id, context) {
|
|
29
|
+
const post = await (0, gallery_service_1.visiblePost)(id, context, context.state.tx);
|
|
30
|
+
if (!post)
|
|
31
|
+
refuse(context, 'unknown-post', NOT_FOUND);
|
|
32
|
+
return post;
|
|
33
|
+
}
|
|
34
|
+
async function ownedOrRefuse(id, context) {
|
|
35
|
+
const post = await visibleOrRefuse(id, context);
|
|
36
|
+
if (post.creatorId !== context.state.user.id)
|
|
37
|
+
refuse(context, 'not-yours', 'only the one who posted it changes or deletes it.');
|
|
38
|
+
return post;
|
|
39
|
+
}
|
|
40
|
+
function checkInput(input, context) {
|
|
41
|
+
const refusal = (0, gallery_rules_1.inputRefusal)(input);
|
|
42
|
+
if (refusal)
|
|
43
|
+
refuse(context, refusal, `the post cannot be kept (${refusal}).`);
|
|
44
|
+
}
|
|
45
|
+
/** The uploads, each checked to be a photo before anything is stored. */
|
|
46
|
+
async function photoUploads(files, context) {
|
|
47
|
+
const out = [];
|
|
48
|
+
for (const file of files ?? []) {
|
|
49
|
+
const upload = await file;
|
|
50
|
+
if (!(0, gallery_rules_1.isPhoto)(upload?.mimetype))
|
|
51
|
+
refuse(context, 'not-a-photo', 'only photos go in the gallery.');
|
|
52
|
+
out.push(file);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** The event a post may hang on - one the person may post to - opened for everyone; refused otherwise. */
|
|
57
|
+
async function eventOrRefuse(eventId, context) {
|
|
58
|
+
const event = await (0, gallery_service_1.maySeeEvent)(eventId, context, context.state.tx);
|
|
59
|
+
if (!event)
|
|
60
|
+
refuse(context, 'unknown-event', 'there is no such event to post to.');
|
|
61
|
+
await (0, gallery_service_1.openEvent)(event.id, context, context.state.tx);
|
|
62
|
+
return event.id;
|
|
63
|
+
}
|
|
64
|
+
const factsOf = (event) => ({
|
|
65
|
+
id: event.id,
|
|
66
|
+
name: event.name,
|
|
67
|
+
startAt: event.startAt,
|
|
68
|
+
endAt: event.endAt,
|
|
69
|
+
location: event.location ?? undefined
|
|
70
|
+
});
|
|
71
|
+
const photoOf = (one) => ({
|
|
72
|
+
id: one.id,
|
|
73
|
+
name: one.name,
|
|
74
|
+
thumbnail: one.thumbnail ?? undefined,
|
|
75
|
+
fullpath: one.fullpath,
|
|
76
|
+
mimetype: one.mimetype ?? undefined
|
|
77
|
+
});
|
|
78
|
+
/** The posts the request's person sees, as a query to narrow further. */
|
|
79
|
+
async function seenPosts(context) {
|
|
80
|
+
const { domain, user } = context.state;
|
|
81
|
+
const viewer = await (0, gallery_service_1.viewerOf)(context);
|
|
82
|
+
const qb = (0, shell_1.getRepository)(gallery_1.GalleryPost).createQueryBuilder('P').where('P.domain = :domain', { domain: domain.id });
|
|
83
|
+
if (!viewer.moderator)
|
|
84
|
+
qb.andWhere('(P.hiddenAt IS NULL OR P.creator = :me)', { me: user.id });
|
|
85
|
+
const active = [...viewer.activePeople];
|
|
86
|
+
/* The own gallery is its owner's until shared (decision 2), and no longer shown when they left (decision 5). */
|
|
87
|
+
qb.andWhere(active.length
|
|
88
|
+
? '(P.space != :personal OR P.creator = :me OR (P.shared = :shared AND P.creator IN (:...active)))'
|
|
89
|
+
: '(P.space != :personal OR P.creator = :me)', {
|
|
90
|
+
personal: gallery_1.GallerySpace.PERSONAL,
|
|
91
|
+
shared: true,
|
|
92
|
+
me: user.id,
|
|
93
|
+
active
|
|
94
|
+
});
|
|
95
|
+
return qb;
|
|
96
|
+
}
|
|
97
|
+
/* Calendar's refusals (createGalleryEvent calls its createEvent) are spoken in the reader's language only through this. */
|
|
98
|
+
let GalleryResolver = class GalleryResolver {
|
|
99
|
+
/* ---------------------------------------------------------------- looking */
|
|
100
|
+
async galleryPosts(filter, skip, take, context) {
|
|
101
|
+
const qb = await seenPosts(context);
|
|
102
|
+
if (filter?.space)
|
|
103
|
+
qb.andWhere('P.space = :space', { space: filter.space });
|
|
104
|
+
if (filter?.eventId)
|
|
105
|
+
qb.andWhere('P.event = :event', { event: filter.eventId });
|
|
106
|
+
if (filter?.authorId)
|
|
107
|
+
qb.andWhere('P.creator = :author', { author: filter.authorId });
|
|
108
|
+
/* The own gallery is the asker's, known here - the client's profile carries no user id (2026-10-31). */
|
|
109
|
+
if (filter?.mine)
|
|
110
|
+
qb.andWhere('P.creator = :me', { me: context.state.user.id });
|
|
111
|
+
/* What a shared screen may show - the screen saver (decision 9): never one's own unshared photos. */
|
|
112
|
+
if (filter?.everyone)
|
|
113
|
+
qb.andWhere('(P.space != :personal OR P.shared = :shared)', { personal: gallery_1.GallerySpace.PERSONAL, shared: true });
|
|
114
|
+
const tag = (0, gallery_rules_1.tagOf)(filter?.tag ?? '');
|
|
115
|
+
/* Tags are kept as a JSON list: the quotes bound the word, so 「워크숍」 does not find 「워크숍2026」. */
|
|
116
|
+
if (tag)
|
|
117
|
+
qb.andWhere('LOWER(P.tags) LIKE :tag', { tag: `%${JSON.stringify(tag.toLowerCase())}%` });
|
|
118
|
+
qb.orderBy('P.createdAt', 'DESC')
|
|
119
|
+
.skip(Math.max(0, skip ?? 0))
|
|
120
|
+
.take(Math.min(60, Math.max(1, take ?? 30)));
|
|
121
|
+
const [items, total] = await qb.getManyAndCount();
|
|
122
|
+
return { items: await (0, gallery_service_1.decorate)(items, context), total };
|
|
123
|
+
}
|
|
124
|
+
async galleryPost(id, context) {
|
|
125
|
+
const post = await (0, gallery_service_1.visiblePost)(id, context);
|
|
126
|
+
return post ? (await (0, gallery_service_1.decorate)([post], context))[0] : undefined;
|
|
127
|
+
}
|
|
128
|
+
async galleryLikers(id, context) {
|
|
129
|
+
const post = await visibleOrRefuse(id, context);
|
|
130
|
+
const likes = await (0, shell_1.getRepository)(gallery_1.GalleryLike).find({
|
|
131
|
+
where: { post: { id: post.id } },
|
|
132
|
+
relations: ['user'],
|
|
133
|
+
order: { createdAt: 'DESC' }
|
|
134
|
+
});
|
|
135
|
+
return likes.map(one => ({ id: one.userId, name: one.user?.name }));
|
|
136
|
+
}
|
|
137
|
+
async galleryTags(text, context) {
|
|
138
|
+
const rows = await (0, shell_1.getRepository)(gallery_1.GalleryPost).find({
|
|
139
|
+
where: { domain: { id: context.state.domain.id }, hiddenAt: (0, typeorm_1.IsNull)() },
|
|
140
|
+
select: ['id', 'tags']
|
|
141
|
+
});
|
|
142
|
+
return (0, gallery_rules_1.tagCounts)(rows.map(one => one.tags), text ?? '');
|
|
143
|
+
}
|
|
144
|
+
async galleryEvents(context) {
|
|
145
|
+
const { domain } = context.state;
|
|
146
|
+
const open = await (0, shell_1.getRepository)(gallery_1.GalleryEvent).find({ where: { domain: { id: domain.id } } });
|
|
147
|
+
if (!open.length)
|
|
148
|
+
return [];
|
|
149
|
+
const events = await (0, shell_1.getRepository)(calendar_1.Event).find({
|
|
150
|
+
where: { id: (0, typeorm_1.In)(open.map(one => one.eventId)), domain: { id: domain.id } },
|
|
151
|
+
order: { startAt: 'DESC' }
|
|
152
|
+
});
|
|
153
|
+
if (!events.length)
|
|
154
|
+
return [];
|
|
155
|
+
const posts = await (await seenPosts(context))
|
|
156
|
+
.andWhere('P.event IN (:...events)', { events: events.map(one => one.id) })
|
|
157
|
+
.orderBy('P.likeCount', 'DESC')
|
|
158
|
+
.addOrderBy('P.createdAt', 'DESC')
|
|
159
|
+
.getMany();
|
|
160
|
+
const byEvent = new Map();
|
|
161
|
+
for (const one of posts)
|
|
162
|
+
byEvent.set(one.eventId, [...(byEvent.get(one.eventId) ?? []), one]);
|
|
163
|
+
const covers = await (0, gallery_service_1.photosOf)([...byEvent.values()].map(list => list[0].id), domain.id);
|
|
164
|
+
return events.map(event => {
|
|
165
|
+
const list = byEvent.get(event.id) ?? [];
|
|
166
|
+
const cover = list.length ? covers.get(list[0].id)?.[0] : undefined;
|
|
167
|
+
return { ...factsOf(event), postCount: list.length, cover: cover ? photoOf(cover) : undefined };
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
async galleryEventChoices(takenAt, context) {
|
|
171
|
+
const at = takenAt && !isNaN(new Date(takenAt).getTime()) ? new Date(takenAt) : new Date();
|
|
172
|
+
const events = await (0, gallery_service_1.eventsSeenBetween)(context, new Date(at.getTime() - 45 * DAY), new Date(at.getTime() + 3 * DAY));
|
|
173
|
+
return (0, gallery_rules_1.orderChoices)(events.map(factsOf), at);
|
|
174
|
+
}
|
|
175
|
+
async gallerySummary(context) {
|
|
176
|
+
const { domain, user } = context.state;
|
|
177
|
+
const visit = await (0, shell_1.getRepository)(gallery_1.GalleryVisit).findOne({
|
|
178
|
+
where: { domain: { id: domain.id }, user: { id: user.id } }
|
|
179
|
+
});
|
|
180
|
+
const since = visit?.seenAt ?? new Date(Date.now() - FIRST_LOOK);
|
|
181
|
+
const fresh = await (await seenPosts(context))
|
|
182
|
+
.andWhere('P.createdAt > :since', { since })
|
|
183
|
+
.andWhere('P.creator != :me', { me: user.id })
|
|
184
|
+
.getCount();
|
|
185
|
+
return { fresh };
|
|
186
|
+
}
|
|
187
|
+
/* ---------------------------------------------------------------- posting */
|
|
188
|
+
async createGalleryPost(input, photos, context) {
|
|
189
|
+
const { domain, user, tx } = context.state;
|
|
190
|
+
checkInput(input, context);
|
|
191
|
+
const countRefusal = (0, gallery_rules_1.photoCountRefusal)(photos?.length ?? 0);
|
|
192
|
+
if (countRefusal)
|
|
193
|
+
refuse(context, countRefusal, `a post holds 1 to 20 photos (${countRefusal}).`);
|
|
194
|
+
const uploads = await photoUploads(photos, context);
|
|
195
|
+
const eventId = input.eventId ? await eventOrRefuse(input.eventId, context) : null;
|
|
196
|
+
const post = await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).save({
|
|
197
|
+
domain,
|
|
198
|
+
space: eventId ? gallery_1.GallerySpace.COMPANY : (input.space ?? gallery_1.GallerySpace.COMPANY),
|
|
199
|
+
shared: !!input.shared,
|
|
200
|
+
caption: input.caption?.trim() || null,
|
|
201
|
+
takenAt: input.takenAt ?? new Date(),
|
|
202
|
+
tags: (0, gallery_rules_1.tagsOf)(input.tags),
|
|
203
|
+
event: eventId ? { id: eventId } : null,
|
|
204
|
+
likeCount: 0,
|
|
205
|
+
creator: user,
|
|
206
|
+
updater: user
|
|
207
|
+
});
|
|
208
|
+
for (const file of uploads)
|
|
209
|
+
await (0, attachment_base_1.createAttachment)(null, { attachment: { file, refType: gallery_service_1.GALLERY_REF_TYPE, refBy: post.id } }, context);
|
|
210
|
+
if (eventId)
|
|
211
|
+
await (0, gallery_service_1.tellFirstPhoto)(context, post, eventId);
|
|
212
|
+
return (await (0, gallery_service_1.decorate)([await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).findOneBy({ id: post.id })], context))[0];
|
|
213
|
+
}
|
|
214
|
+
async updateGalleryPost(id, input, attach, remove, context) {
|
|
215
|
+
const { domain, user, tx } = context.state;
|
|
216
|
+
const post = await ownedOrRefuse(id, context);
|
|
217
|
+
checkInput(input, context);
|
|
218
|
+
const current = (await (0, gallery_service_1.photosOf)([post.id], domain.id, tx)).get(post.id) ?? [];
|
|
219
|
+
const removing = current.filter(one => (remove ?? []).includes(one.id));
|
|
220
|
+
const countRefusal = (0, gallery_rules_1.photoCountRefusal)(current.length - removing.length + (attach?.length ?? 0));
|
|
221
|
+
if (countRefusal)
|
|
222
|
+
refuse(context, countRefusal, `a post holds 1 to 20 photos (${countRefusal}).`);
|
|
223
|
+
const uploads = await photoUploads(attach, context);
|
|
224
|
+
const eventId = input.eventId
|
|
225
|
+
? input.eventId === post.eventId
|
|
226
|
+
? post.eventId
|
|
227
|
+
: await eventOrRefuse(input.eventId, context)
|
|
228
|
+
: null;
|
|
229
|
+
await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).update(post.id, {
|
|
230
|
+
space: eventId ? gallery_1.GallerySpace.COMPANY : (input.space ?? post.space),
|
|
231
|
+
shared: input.shared ?? post.shared,
|
|
232
|
+
caption: input.caption?.trim() || null,
|
|
233
|
+
takenAt: input.takenAt ?? post.takenAt,
|
|
234
|
+
tags: (0, gallery_rules_1.tagsOf)(input.tags),
|
|
235
|
+
event: eventId ? { id: eventId } : null,
|
|
236
|
+
updater: user
|
|
237
|
+
});
|
|
238
|
+
for (const one of removing)
|
|
239
|
+
await (0, attachment_base_1.deleteAttachment)(null, { id: one.id }, context);
|
|
240
|
+
for (const file of uploads)
|
|
241
|
+
await (0, attachment_base_1.createAttachment)(null, { attachment: { file, refType: gallery_service_1.GALLERY_REF_TYPE, refBy: post.id } }, context);
|
|
242
|
+
if (eventId && eventId !== post.eventId)
|
|
243
|
+
await (0, gallery_service_1.tellFirstPhoto)(context, post, eventId);
|
|
244
|
+
return (await (0, gallery_service_1.decorate)([await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).findOneBy({ id: post.id })], context))[0];
|
|
245
|
+
}
|
|
246
|
+
async deleteGalleryPost(id, context) {
|
|
247
|
+
const { tx, user } = context.state;
|
|
248
|
+
const post = await ownedOrRefuse(id, context);
|
|
249
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [post.id], refType: gallery_service_1.GALLERY_REF_TYPE }, context);
|
|
250
|
+
await (0, shell_1.getRepository)(gallery_1.GalleryLike, tx).softDelete({ post: { id: post.id } });
|
|
251
|
+
await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).update(post.id, { updater: user });
|
|
252
|
+
await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).softDelete(post.id);
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
async likeGalleryPost(id, like, context) {
|
|
256
|
+
const { domain, user, tx } = context.state;
|
|
257
|
+
const post = await visibleOrRefuse(id, context);
|
|
258
|
+
const repository = (0, shell_1.getRepository)(gallery_1.GalleryLike, tx);
|
|
259
|
+
const mine = await repository.findOne({ where: { post: { id: post.id }, user: { id: user.id } } });
|
|
260
|
+
if (like && !mine)
|
|
261
|
+
await repository.save({
|
|
262
|
+
domain,
|
|
263
|
+
post: { id: post.id },
|
|
264
|
+
user: { id: user.id },
|
|
265
|
+
creator: user,
|
|
266
|
+
updater: user
|
|
267
|
+
});
|
|
268
|
+
if (!like && mine)
|
|
269
|
+
await repository.softDelete(mine.id);
|
|
270
|
+
const likeCount = await repository.count({ where: { post: { id: post.id } } });
|
|
271
|
+
await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).update(post.id, { likeCount });
|
|
272
|
+
return { id: post.id, likeCount, liked: like };
|
|
273
|
+
}
|
|
274
|
+
async visitGallery(context) {
|
|
275
|
+
const { domain, user, tx } = context.state;
|
|
276
|
+
const repository = (0, shell_1.getRepository)(gallery_1.GalleryVisit, tx);
|
|
277
|
+
const visit = await repository.findOne({ where: { domain: { id: domain.id }, user: { id: user.id } } });
|
|
278
|
+
if (visit)
|
|
279
|
+
await repository.update(visit.id, { seenAt: new Date(), updater: user });
|
|
280
|
+
else
|
|
281
|
+
await repository.save({ domain, user: { id: user.id }, seenAt: new Date(), creator: user, updater: user });
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
/* ---------------------------------------------------------------- moderating */
|
|
285
|
+
async hideGalleryPost(id, reason, context) {
|
|
286
|
+
const { user, tx } = context.state;
|
|
287
|
+
const post = await visibleOrRefuse(id, context);
|
|
288
|
+
const why = (reason ?? '').trim();
|
|
289
|
+
if (!why)
|
|
290
|
+
refuse(context, 'reason-required', 'give the reason it is hidden.');
|
|
291
|
+
if (why.length > 200)
|
|
292
|
+
refuse(context, 'reason-too-long', 'the reason is at most 200 characters.');
|
|
293
|
+
await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).update(post.id, {
|
|
294
|
+
hiddenAt: new Date(),
|
|
295
|
+
hiddenReason: why,
|
|
296
|
+
hiddenBy: user,
|
|
297
|
+
updater: user
|
|
298
|
+
});
|
|
299
|
+
await (0, gallery_service_1.tellHidden)(context, post, why);
|
|
300
|
+
return (await (0, gallery_service_1.decorate)([await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).findOneBy({ id: post.id })], context))[0];
|
|
301
|
+
}
|
|
302
|
+
async unhideGalleryPost(id, context) {
|
|
303
|
+
const { user, tx } = context.state;
|
|
304
|
+
const post = await visibleOrRefuse(id, context);
|
|
305
|
+
await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).update(post.id, {
|
|
306
|
+
hiddenAt: null,
|
|
307
|
+
hiddenReason: null,
|
|
308
|
+
hiddenBy: null,
|
|
309
|
+
updater: user
|
|
310
|
+
});
|
|
311
|
+
return (await (0, gallery_service_1.decorate)([await (0, shell_1.getRepository)(gallery_1.GalleryPost, tx).findOneBy({ id: post.id })], context))[0];
|
|
312
|
+
}
|
|
313
|
+
async renameGalleryTag(from, to, context) {
|
|
314
|
+
const { domain, user, tx } = context.state;
|
|
315
|
+
const target = (0, gallery_rules_1.tagOf)(to);
|
|
316
|
+
if (!(0, gallery_rules_1.tagOf)(from) || !target)
|
|
317
|
+
refuse(context, 'tag-required', 'give the tag and its new name.');
|
|
318
|
+
if (target.length > gallery_rules_1.MAX_TAG)
|
|
319
|
+
refuse(context, 'tag-too-long', 'a tag is at most 30 characters.');
|
|
320
|
+
const repository = (0, shell_1.getRepository)(gallery_1.GalleryPost, tx);
|
|
321
|
+
const rows = await repository.find({
|
|
322
|
+
where: { domain: { id: domain.id }, tags: (0, typeorm_1.Not)((0, typeorm_1.IsNull)()) },
|
|
323
|
+
select: ['id', 'tags']
|
|
324
|
+
});
|
|
325
|
+
let changed = 0;
|
|
326
|
+
for (const one of rows) {
|
|
327
|
+
if (!(0, gallery_rules_1.hasTag)(one.tags, from))
|
|
328
|
+
continue;
|
|
329
|
+
await repository.update(one.id, { tags: (0, gallery_rules_1.renamedTags)(one.tags, from, target), updater: user });
|
|
330
|
+
changed++;
|
|
331
|
+
}
|
|
332
|
+
return changed;
|
|
333
|
+
}
|
|
334
|
+
async createGalleryEvent(input, context) {
|
|
335
|
+
const { domain, user, tx } = context.state;
|
|
336
|
+
const event = await (0, calendar_1.createEvent)(tx, domain, user, {
|
|
337
|
+
name: input.name,
|
|
338
|
+
startAt: input.startAt,
|
|
339
|
+
endAt: input.endAt,
|
|
340
|
+
location: input.location
|
|
341
|
+
});
|
|
342
|
+
await (0, gallery_service_1.openEvent)(event.id, context, tx);
|
|
343
|
+
return { ...factsOf(event), postCount: 0 };
|
|
344
|
+
}
|
|
345
|
+
/* ---------------------------------------------------------------- a post's fields */
|
|
346
|
+
async photos(post, context) {
|
|
347
|
+
const rows = post.__photos ?? (await (0, gallery_service_1.photosOf)([post.id], context.state.domain.id)).get(post.id) ?? [];
|
|
348
|
+
return rows.map(photoOf);
|
|
349
|
+
}
|
|
350
|
+
async creator(post) {
|
|
351
|
+
if (post.__creator !== undefined)
|
|
352
|
+
return post.__creator ?? undefined;
|
|
353
|
+
return post.creatorId ? await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: post.creatorId }) : undefined;
|
|
354
|
+
}
|
|
355
|
+
async event(post) {
|
|
356
|
+
const event = post.__event ?? (post.eventId ? await (0, shell_1.getRepository)(calendar_1.Event).findOneBy({ id: post.eventId }) : null);
|
|
357
|
+
return event ? factsOf(event) : undefined;
|
|
358
|
+
}
|
|
359
|
+
async liked(post, context) {
|
|
360
|
+
if (post.__liked !== undefined)
|
|
361
|
+
return post.__liked;
|
|
362
|
+
return !!(await (0, shell_1.getRepository)(gallery_1.GalleryLike).findOne({
|
|
363
|
+
where: { post: { id: post.id }, user: { id: context.state.user.id } }
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
editable(post, context) {
|
|
367
|
+
return post.creatorId === context.state.user?.id;
|
|
368
|
+
}
|
|
369
|
+
async moderatable(context) {
|
|
370
|
+
return await (0, gallery_service_1.isModerator)(context);
|
|
371
|
+
}
|
|
372
|
+
async hiddenReason(post, context) {
|
|
373
|
+
if (!post.hiddenAt)
|
|
374
|
+
return undefined;
|
|
375
|
+
return post.creatorId === context.state.user?.id || (await (0, gallery_service_1.isModerator)(context)) ? post.hiddenReason : undefined;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
exports.GalleryResolver = GalleryResolver;
|
|
379
|
+
tslib_1.__decorate([
|
|
380
|
+
(0, type_graphql_1.Query)(returns => gallery_types_1.GalleryPostList, {
|
|
381
|
+
description: 'The posts the person sees, newest first - narrowed by space, event, tag or person.'
|
|
382
|
+
}),
|
|
383
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('filter', type => gallery_types_1.GalleryFilter, { nullable: true })),
|
|
384
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('skip', type => type_graphql_1.Int, { nullable: true })),
|
|
385
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('take', type => type_graphql_1.Int, { nullable: true })),
|
|
386
|
+
tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
|
|
387
|
+
tslib_1.__metadata("design:type", Function),
|
|
388
|
+
tslib_1.__metadata("design:paramtypes", [gallery_types_1.GalleryFilter, Number, Number, Object]),
|
|
389
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
390
|
+
], GalleryResolver.prototype, "galleryPosts", null);
|
|
391
|
+
tslib_1.__decorate([
|
|
392
|
+
(0, type_graphql_1.Query)(returns => gallery_1.GalleryPost, { nullable: true, description: 'One post, when the person sees it.' }),
|
|
393
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
394
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
395
|
+
tslib_1.__metadata("design:type", Function),
|
|
396
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
397
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
398
|
+
], GalleryResolver.prototype, "galleryPost", null);
|
|
399
|
+
tslib_1.__decorate([
|
|
400
|
+
(0, type_graphql_1.Query)(returns => [gallery_types_1.GalleryPerson], { description: 'Who likes the post, the latest first.' }),
|
|
401
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
402
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
403
|
+
tslib_1.__metadata("design:type", Function),
|
|
404
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
405
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
406
|
+
], GalleryResolver.prototype, "galleryLikers", null);
|
|
407
|
+
tslib_1.__decorate([
|
|
408
|
+
(0, type_graphql_1.Query)(returns => [gallery_types_1.GalleryTagCount], {
|
|
409
|
+
description: 'The tags of the domain the most used first - those holding `text` when given.'
|
|
410
|
+
}),
|
|
411
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('text', { nullable: true })),
|
|
412
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
413
|
+
tslib_1.__metadata("design:type", Function),
|
|
414
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
415
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
416
|
+
], GalleryResolver.prototype, "galleryTags", null);
|
|
417
|
+
tslib_1.__decorate([
|
|
418
|
+
(0, type_graphql_1.Query)(returns => [gallery_types_1.GalleryEventCard], {
|
|
419
|
+
description: 'The events whose gallery is open, the latest first, each with its posts counted and a photo shown.'
|
|
420
|
+
}),
|
|
421
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
422
|
+
tslib_1.__metadata("design:type", Function),
|
|
423
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
424
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
425
|
+
], GalleryResolver.prototype, "galleryEvents", null);
|
|
426
|
+
tslib_1.__decorate([
|
|
427
|
+
(0, type_graphql_1.Query)(returns => [gallery_types_1.GalleryEventChoice], {
|
|
428
|
+
description: 'The events the person may post photos to - those near when the photo was taken first. Their own events, the open ones, and every event for whoever reads the calendar.'
|
|
429
|
+
}),
|
|
430
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('takenAt', { nullable: true })),
|
|
431
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
432
|
+
tslib_1.__metadata("design:type", Function),
|
|
433
|
+
tslib_1.__metadata("design:paramtypes", [Date, Object]),
|
|
434
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
435
|
+
], GalleryResolver.prototype, "galleryEventChoices", null);
|
|
436
|
+
tslib_1.__decorate([
|
|
437
|
+
(0, type_graphql_1.Query)(returns => gallery_types_1.GallerySummary, {
|
|
438
|
+
description: 'How many posts others made since the person last opened the gallery.'
|
|
439
|
+
}),
|
|
440
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
441
|
+
tslib_1.__metadata("design:type", Function),
|
|
442
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
443
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
444
|
+
], GalleryResolver.prototype, "gallerySummary", null);
|
|
445
|
+
tslib_1.__decorate([
|
|
446
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
447
|
+
(0, type_graphql_1.Mutation)(returns => gallery_1.GalleryPost, {
|
|
448
|
+
description: 'Posts photos - at least one - with a caption, tags and an event when given.'
|
|
449
|
+
}),
|
|
450
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('input', type => gallery_types_1.GalleryPostInput)),
|
|
451
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('photos', type => [GraphQLUpload_js_1.default])),
|
|
452
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
453
|
+
tslib_1.__metadata("design:type", Function),
|
|
454
|
+
tslib_1.__metadata("design:paramtypes", [gallery_types_1.GalleryPostInput, Array, Object]),
|
|
455
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
456
|
+
], GalleryResolver.prototype, "createGalleryPost", null);
|
|
457
|
+
tslib_1.__decorate([
|
|
458
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
459
|
+
(0, type_graphql_1.Mutation)(returns => gallery_1.GalleryPost, {
|
|
460
|
+
description: "Changes one's own post - its caption, tags, space, event and photos; at least one photo stays."
|
|
461
|
+
}),
|
|
462
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
463
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('input', type => gallery_types_1.GalleryPostInput)),
|
|
464
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('attach', type => [GraphQLUpload_js_1.default], { nullable: true })),
|
|
465
|
+
tslib_1.__param(3, (0, type_graphql_1.Arg)('remove', type => [String], { nullable: true })),
|
|
466
|
+
tslib_1.__param(4, (0, type_graphql_1.Ctx)()),
|
|
467
|
+
tslib_1.__metadata("design:type", Function),
|
|
468
|
+
tslib_1.__metadata("design:paramtypes", [String, gallery_types_1.GalleryPostInput, Array, Array, Object]),
|
|
469
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
470
|
+
], GalleryResolver.prototype, "updateGalleryPost", null);
|
|
471
|
+
tslib_1.__decorate([
|
|
472
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
473
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: "Deletes one's own post with its photos." }),
|
|
474
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
475
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
476
|
+
tslib_1.__metadata("design:type", Function),
|
|
477
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
478
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
479
|
+
], GalleryResolver.prototype, "deleteGalleryPost", null);
|
|
480
|
+
tslib_1.__decorate([
|
|
481
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
482
|
+
(0, type_graphql_1.Mutation)(returns => gallery_types_1.GalleryLikeState, {
|
|
483
|
+
description: 'Likes a post, or takes the like back - liking it twice changes nothing.'
|
|
484
|
+
}),
|
|
485
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
486
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('like')),
|
|
487
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
488
|
+
tslib_1.__metadata("design:type", Function),
|
|
489
|
+
tslib_1.__metadata("design:paramtypes", [String, Boolean, Object]),
|
|
490
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
491
|
+
], GalleryResolver.prototype, "likeGalleryPost", null);
|
|
492
|
+
tslib_1.__decorate([
|
|
493
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
494
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, {
|
|
495
|
+
description: 'Records that the person opened the gallery - the menu counts the posts after it.'
|
|
496
|
+
}),
|
|
497
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
498
|
+
tslib_1.__metadata("design:type", Function),
|
|
499
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
500
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
501
|
+
], GalleryResolver.prototype, "visitGallery", null);
|
|
502
|
+
tslib_1.__decorate([
|
|
503
|
+
(0, type_graphql_1.Directive)(MODERATE),
|
|
504
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
505
|
+
(0, type_graphql_1.Mutation)(returns => gallery_1.GalleryPost, {
|
|
506
|
+
description: 'Hides a post with the reason - its owner is told, and still sees it marked hidden. Undone by unhideGalleryPost.'
|
|
507
|
+
}),
|
|
508
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
509
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('reason')),
|
|
510
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
511
|
+
tslib_1.__metadata("design:type", Function),
|
|
512
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
513
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
514
|
+
], GalleryResolver.prototype, "hideGalleryPost", null);
|
|
515
|
+
tslib_1.__decorate([
|
|
516
|
+
(0, type_graphql_1.Directive)(MODERATE),
|
|
517
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
518
|
+
(0, type_graphql_1.Mutation)(returns => gallery_1.GalleryPost, { description: 'Shows a hidden post again.' }),
|
|
519
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
520
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
521
|
+
tslib_1.__metadata("design:type", Function),
|
|
522
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
523
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
524
|
+
], GalleryResolver.prototype, "unhideGalleryPost", null);
|
|
525
|
+
tslib_1.__decorate([
|
|
526
|
+
(0, type_graphql_1.Directive)(MODERATE),
|
|
527
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
528
|
+
(0, type_graphql_1.Mutation)(returns => type_graphql_1.Int, {
|
|
529
|
+
description: 'Renames a tag on every post of the domain - into a tag already there, the two become one. Answers how many posts changed.'
|
|
530
|
+
}),
|
|
531
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('from')),
|
|
532
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('to')),
|
|
533
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
534
|
+
tslib_1.__metadata("design:type", Function),
|
|
535
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
536
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
537
|
+
], GalleryResolver.prototype, "renameGalleryTag", null);
|
|
538
|
+
tslib_1.__decorate([
|
|
539
|
+
(0, type_graphql_1.Directive)(MODERATE),
|
|
540
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
541
|
+
(0, type_graphql_1.Mutation)(returns => gallery_types_1.GalleryEventCard, {
|
|
542
|
+
description: 'Makes a company event on the calendar and opens its gallery - for the events nobody put on the calendar yet.'
|
|
543
|
+
}),
|
|
544
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('input', type => gallery_types_1.GalleryEventInput)),
|
|
545
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
546
|
+
tslib_1.__metadata("design:type", Function),
|
|
547
|
+
tslib_1.__metadata("design:paramtypes", [gallery_types_1.GalleryEventInput, Object]),
|
|
548
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
549
|
+
], GalleryResolver.prototype, "createGalleryEvent", null);
|
|
550
|
+
tslib_1.__decorate([
|
|
551
|
+
(0, type_graphql_1.FieldResolver)(type => [gallery_types_1.GalleryPhoto], { description: 'The photos, in the order they were added.' }),
|
|
552
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
553
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
554
|
+
tslib_1.__metadata("design:type", Function),
|
|
555
|
+
tslib_1.__metadata("design:paramtypes", [gallery_1.GalleryPost, Object]),
|
|
556
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
557
|
+
], GalleryResolver.prototype, "photos", null);
|
|
558
|
+
tslib_1.__decorate([
|
|
559
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true, description: 'Who posted it - the owner.' }),
|
|
560
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
561
|
+
tslib_1.__metadata("design:type", Function),
|
|
562
|
+
tslib_1.__metadata("design:paramtypes", [gallery_1.GalleryPost]),
|
|
563
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
564
|
+
], GalleryResolver.prototype, "creator", null);
|
|
565
|
+
tslib_1.__decorate([
|
|
566
|
+
(0, type_graphql_1.FieldResolver)(type => gallery_types_1.GalleryEventFacts, {
|
|
567
|
+
nullable: true,
|
|
568
|
+
description: 'The event the photos are of - its name, time and place.'
|
|
569
|
+
}),
|
|
570
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
571
|
+
tslib_1.__metadata("design:type", Function),
|
|
572
|
+
tslib_1.__metadata("design:paramtypes", [gallery_1.GalleryPost]),
|
|
573
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
574
|
+
], GalleryResolver.prototype, "event", null);
|
|
575
|
+
tslib_1.__decorate([
|
|
576
|
+
(0, type_graphql_1.FieldResolver)(type => Boolean, { description: 'Whether the person likes it.' }),
|
|
577
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
578
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
579
|
+
tslib_1.__metadata("design:type", Function),
|
|
580
|
+
tslib_1.__metadata("design:paramtypes", [gallery_1.GalleryPost, Object]),
|
|
581
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
582
|
+
], GalleryResolver.prototype, "liked", null);
|
|
583
|
+
tslib_1.__decorate([
|
|
584
|
+
(0, type_graphql_1.FieldResolver)(type => Boolean, { description: "Whether it is the person's own - they change and delete it." }),
|
|
585
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
586
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
587
|
+
tslib_1.__metadata("design:type", Function),
|
|
588
|
+
tslib_1.__metadata("design:paramtypes", [gallery_1.GalleryPost, Object]),
|
|
589
|
+
tslib_1.__metadata("design:returntype", Boolean)
|
|
590
|
+
], GalleryResolver.prototype, "editable", null);
|
|
591
|
+
tslib_1.__decorate([
|
|
592
|
+
(0, type_graphql_1.FieldResolver)(type => Boolean, { description: 'Whether the person may hide it or show it again.' }),
|
|
593
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
594
|
+
tslib_1.__metadata("design:type", Function),
|
|
595
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
596
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
597
|
+
], GalleryResolver.prototype, "moderatable", null);
|
|
598
|
+
tslib_1.__decorate([
|
|
599
|
+
(0, type_graphql_1.FieldResolver)(type => String, {
|
|
600
|
+
nullable: true,
|
|
601
|
+
description: 'Why it was hidden - for its owner and the moderators.'
|
|
602
|
+
}),
|
|
603
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
604
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
605
|
+
tslib_1.__metadata("design:type", Function),
|
|
606
|
+
tslib_1.__metadata("design:paramtypes", [gallery_1.GalleryPost, Object]),
|
|
607
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
608
|
+
], GalleryResolver.prototype, "hiddenReason", null);
|
|
609
|
+
exports.GalleryResolver = GalleryResolver = tslib_1.__decorate([
|
|
610
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
|
|
611
|
+
(0, type_graphql_1.Resolver)(gallery_1.GalleryPost)
|
|
612
|
+
], GalleryResolver);
|
|
613
|
+
//# sourceMappingURL=gallery-resolver.js.map
|