Skip to content

Commit 2c8109c

Browse files
refactor(syndicator-mastodon): remove ‘toot’
1 parent 761afbc commit 2c8109c

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

packages/syndicator-mastodon/lib/mastodon.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ export const mastodon = ({ accessToken, characterLimit, serverUrl }) => ({
1111

1212
/**
1313
* Post a favourite
14-
* @param {string} tootUrl - URL of toot to favourite
14+
* @param {string} statusUrl - URL of status to favourite
1515
* @returns {Promise<string>} Mastodon status URL
1616
*/
17-
async postFavourite(tootUrl) {
18-
const statusId = getStatusIdFromUrl(tootUrl);
17+
async postFavourite(statusUrl) {
18+
const statusId = getStatusIdFromUrl(statusUrl);
1919
const { data } = await this.client().favouriteStatus(statusId);
2020
return data.url;
2121
},
2222

2323
/**
2424
* Post a reblog
25-
* @param {string} tootUrl - URL of toot to reblog
25+
* @param {string} statusUrl - URL of status to reblog
2626
* @returns {Promise<string>} Mastodon status URL
2727
*/
28-
async postReblog(tootUrl) {
29-
const statusId = getStatusIdFromUrl(tootUrl);
28+
async postReblog(statusUrl) {
29+
const statusId = getStatusIdFromUrl(statusUrl);
3030
const { data } = await this.client().reblogStatus(statusId);
3131
return data.url;
3232
},
@@ -76,7 +76,7 @@ export const mastodon = ({ accessToken, characterLimit, serverUrl }) => ({
7676
* Post to Mastodon
7777
* @param {object} properties - JF2 properties object
7878
* @param {string} me - Publication URL
79-
* @returns {Promise<string|boolean>} URL of syndicated toot
79+
* @returns {Promise<string|boolean>} URL of syndicated status
8080
*/
8181
async post(properties, me) {
8282
let mediaIds = [];

packages/syndicator-mastodon/lib/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ export const createStatus = (properties, options = {}) => {
5050
parameters.media_ids = mediaIds;
5151
}
5252

53-
// If post is in reply to a toot, add respective parameter
53+
// If post is in reply to a status, add respective parameter
5454
if (properties["in-reply-to"]) {
5555
const inReplyTo = properties["in-reply-to"];
5656
const inReplyToHostname = new URL(inReplyTo).hostname;
5757
const serverHostname = new URL(serverUrl).hostname;
5858

5959
if (inReplyToHostname === serverHostname) {
60-
// Reply to toot
60+
// Reply to status
6161
const statusId = getStatusIdFromUrl(inReplyTo);
6262
parameters.in_reply_to_status_id = statusId;
6363
} else {

packages/syndicator-mastodon/tests/unit/mastodon.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test.beforeEach((t) => {
2424
},
2525
status: "Toot",
2626
statusId: "1234567890987654321",
27-
tootUrl: "https://mastodon.example/@username/1234567890987654321",
27+
statusUrl: "https://mastodon.example/@username/1234567890987654321",
2828
};
2929
});
3030

@@ -34,7 +34,7 @@ test("Posts a favourite", async (t) => {
3434
.reply(200, t.context.apiResponse);
3535

3636
const result = await mastodon(t.context.options).postFavourite(
37-
t.context.tootUrl
37+
t.context.statusUrl
3838
);
3939

4040
t.is(result, `https://mastodon.example/@username/${t.context.statusId}`);
@@ -46,7 +46,7 @@ test("Throws error posting a favourite", async (t) => {
4646
.reply(404, { message: "Not found" });
4747

4848
await t.throwsAsync(
49-
mastodon(t.context.options).postFavourite(t.context.tootUrl),
49+
mastodon(t.context.options).postFavourite(t.context.statusUrl),
5050
{
5151
message: "Request failed with status code 404",
5252
}
@@ -59,7 +59,7 @@ test("Posts a reblog", async (t) => {
5959
.reply(200, t.context.apiResponse);
6060

6161
const result = await mastodon(t.context.options).postReblog(
62-
t.context.tootUrl
62+
t.context.statusUrl
6363
);
6464

6565
t.is(result, `https://mastodon.example/@username/${t.context.statusId}`);
@@ -71,7 +71,7 @@ test("Throws error posting a reblog", async (t) => {
7171
.reply(404, { message: "Not found" });
7272

7373
await t.throwsAsync(
74-
mastodon(t.context.options).postReblog(t.context.tootUrl),
74+
mastodon(t.context.options).postReblog(t.context.statusUrl),
7575
{
7676
message: "Request failed with status code 404",
7777
}
@@ -156,14 +156,14 @@ test("Returns false passing an object to media upload function", async (t) => {
156156
t.falsy(result);
157157
});
158158

159-
test("Posts a favourite of a toot to Mastodon", async (t) => {
159+
test("Posts a favourite of a Mastodon status to Mastodon", async (t) => {
160160
nock(t.context.options.serverUrl)
161161
.post(`/api/v1/statuses/${t.context.statusId}/favourite`)
162162
.reply(200, t.context.apiResponse);
163163

164164
const result = await mastodon(t.context.options).post(
165165
{
166-
"like-of": t.context.tootUrl,
166+
"like-of": t.context.statusUrl,
167167
},
168168
t.context.me
169169
);
@@ -182,14 +182,14 @@ test("Doesn’t post a favourite of a URL to Mastodon", async (t) => {
182182
t.falsy(result);
183183
});
184184

185-
test("Posts a repost of a toot to Mastodon", async (t) => {
185+
test("Posts a repost of a Mastodon status to Mastodon", async (t) => {
186186
nock(t.context.options.serverUrl)
187187
.post(`/api/v1/statuses/${t.context.statusId}/reblog`)
188188
.reply(200, t.context.apiResponse);
189189

190190
const result = await mastodon(t.context.options).post(
191191
{
192-
"repost-of": t.context.tootUrl,
192+
"repost-of": t.context.statusUrl,
193193
},
194194
t.context.me
195195
);
@@ -218,7 +218,7 @@ test("Posts a quote status to Mastodon", async (t) => {
218218
content: {
219219
html: "<p>Someone else who likes cheese sandwiches.</p>",
220220
},
221-
"repost-of": t.context.tootUrl,
221+
"repost-of": t.context.statusUrl,
222222
"post-type": "repost",
223223
},
224224
t.context.me

packages/syndicator-mastodon/tests/unit/utils.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ import {
77
htmlToStatusText,
88
} from "../../lib/utils.js";
99

10-
test.beforeEach((t) => {
11-
t.context = {
12-
me: "https://website.example",
13-
tootUrl: "https://mastodon.example/@username/1234567890987654321",
14-
};
15-
});
16-
1710
test("Creates a status with article post name and URL", (t) => {
1811
const result = createStatus(
1912
JSON.parse(getFixture("jf2/article-content-provided-html-text.jf2")),
@@ -73,7 +66,7 @@ test("Creates a reblog with status URL and post content", (t) => {
7366

7467
t.is(
7568
result.status,
76-
`Someone else who likes cheese sandwiches. ${t.context.tootUrl}`
69+
`Someone else who likes cheese sandwiches. https://mastodon.example/@username/1234567890987654321`
7770
);
7871
});
7972

0 commit comments

Comments
 (0)