Skip to content

Commit cf98058

Browse files
authored
Merge pull request #22 from fbsamples/link-attachment
Link Attachment
2 parents 6384d5f + 697ea41 commit cf98058

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const FIELD__FOLLOWERS_COUNT = 'followers_count';
2626
const FIELD__HIDE_STATUS = 'hide_status';
2727
const FIELD__IS_REPLY = 'is_reply';
2828
const FIELD__LIKES = 'likes';
29+
const FIELD__LINK_ATTACHMENT_URL = 'link_attachment_url';
2930
const FIELD__MEDIA_TYPE = 'media_type';
3031
const FIELD__MEDIA_URL = 'media_url';
3132
const FIELD__PERMALINK = 'permalink';
@@ -52,6 +53,7 @@ const PARAMS__CLIENT_ID = 'client_id';
5253
const PARAMS__CONFIG = 'config';
5354
const PARAMS__FIELDS = 'fields';
5455
const PARAMS__HIDE = 'hide';
56+
const PARAMS__LINK_ATTACHMENT = 'link_attachment';
5557
const PARAMS__METRIC = 'metric';
5658
const PARAMS__QUOTA_USAGE = 'quota_usage';
5759
const PARAMS__REDIRECT_URI = 'redirect_uri';
@@ -300,11 +302,12 @@ app.get('/upload', loggedInUserChecker, (req, res) => {
300302
});
301303

302304
app.post('/upload', upload.array(), async (req, res) => {
303-
const { text, attachmentType, attachmentUrl, attachmentAltText, replyControl, replyToId } = req.body;
305+
const { text, attachmentType, attachmentUrl, attachmentAltText, replyControl, replyToId, linkAttachment } = req.body;
304306
const params = {
305307
[PARAMS__TEXT]: text,
306308
[PARAMS__REPLY_CONTROL]: replyControl,
307309
[PARAMS__REPLY_TO_ID]: replyToId,
310+
[PARAMS__LINK_ATTACHMENT]: linkAttachment
308311
};
309312

310313
// No attachments
@@ -434,6 +437,7 @@ app.get('/threads/:threadId', loggedInUserChecker, async (req, res) => {
434437
FIELD__USERNAME,
435438
FIELD__REPLY_AUDIENCE,
436439
FIELD__ALT_TEXT,
440+
FIELD__LINK_ATTACHMENT_URL,
437441
].join(','),
438442
}, req.session.access_token);
439443

views/thread.pug

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ block content
2323
tr
2424
td Alt Text
2525
td #{alt_text}
26+
tr
27+
td Link Attachment URL
28+
td #{link_attachment_url}
2629
tr
2730
td Permalink
2831
td

views/upload.pug

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ block content
3939
img {
4040
margin-bottom: 15px;
4141
}
42+
#reply-control {
43+
margin-bottom: 15px;
44+
}
45+
#link-attachment {
46+
width: 200px;
47+
}
4248

4349
if (replyToId !== undefined)
4450
p(style='color: gray') Replying to #{replyToId}
@@ -61,6 +67,10 @@ block content
6167
option(value="accounts_you_follow") Accounts You Follow
6268
option(value="mentioned_only") Mentioned Only
6369

70+
label(for='linkAttachment')
71+
| Link Attachment
72+
input#link-attachment(type='text' name='linkAttachment' value='')
73+
6474
input(type='hidden' name='replyToId' value=replyToId)
6575
input.threads-button(type='submit' id='submit' value='Post')
6676

0 commit comments

Comments
 (0)