diff --git a/bin/mastodon-data.js b/bin/mastodon-data.js index 66206f3..46584d2 100644 --- a/bin/mastodon-data.js +++ b/bin/mastodon-data.js @@ -326,5 +326,12 @@ export const actions = times(30, i => ({ inReplyTo: 'bazthread-thread 2b2', privacy: 'unlisted' } + }, + { + user: 'LockedAccount', + post: { + text: 'This account is locked', + privacy: 'private' + } } ])) diff --git a/bin/svgs.js b/bin/svgs.js index cbf13f9..e4bd6a7 100644 --- a/bin/svgs.js +++ b/bin/svgs.js @@ -30,5 +30,6 @@ module.exports = [ {id: 'fa-smile', src: 'node_modules/font-awesome-svg-png/white/svg/smile-o.svg', title: 'Custom emoji'}, {id: 'fa-exclamation-triangle', src: 'node_modules/font-awesome-svg-png/white/svg/exclamation-triangle.svg', title: 'Content warning'}, {id: 'fa-check', src: 'node_modules/font-awesome-svg-png/white/svg/check.svg', title: 'Check'}, - {id: 'fa-trash', src: 'node_modules/font-awesome-svg-png/white/svg/trash-o.svg', title: 'Delete'} + {id: 'fa-trash', src: 'node_modules/font-awesome-svg-png/white/svg/trash-o.svg', title: 'Delete'}, + {id: 'fa-hourglass', src: 'node_modules/font-awesome-svg-png/white/svg/hourglass.svg', title: 'Follow requested'} ] diff --git a/fixtures/dump.sql b/fixtures/dump.sql index a2038b2..af6f4d8 100644 Binary files a/fixtures/dump.sql and b/fixtures/dump.sql differ diff --git a/fixtures/system.tgz b/fixtures/system.tgz index acf3a07..92fcc8f 100644 Binary files a/fixtures/system.tgz and b/fixtures/system.tgz differ diff --git a/routes/_actions/follow.js b/routes/_actions/follow.js index cf5ccf5..9f9c1c0 100644 --- a/routes/_actions/follow.js +++ b/routes/_actions/follow.js @@ -2,6 +2,7 @@ import { store } from '../_store/store' import { followAccount, unfollowAccount } from '../_api/follow' import { database } from '../_database/database' import { toast } from '../_utils/toast' +import { updateProfileAndRelationship } from './accounts' export async function setAccountFollowed (accountId, follow, toastOnSuccess) { let instanceName = store.get('currentInstance') @@ -12,11 +13,18 @@ export async function setAccountFollowed (accountId, follow, toastOnSuccess) { } else { await unfollowAccount(instanceName, accessToken, accountId) } + await updateProfileAndRelationship(accountId) let relationship = await database.getRelationship(instanceName, accountId) - relationship.following = follow - await database.setRelationship(instanceName, relationship) if (toastOnSuccess) { - toast.say(`${follow ? 'Followed' : 'Unfollowed'}`) + if (follow) { + if (relationship.requested) { + toast.say('Requested to follow account') + } else { + toast.say('Followed account') + } + } else { + toast.say('Unfollowed account') + } } } catch (e) { console.error(e) diff --git a/routes/_actions/followRequests.js b/routes/_actions/followRequests.js new file mode 100644 index 0000000..42427cb --- /dev/null +++ b/routes/_actions/followRequests.js @@ -0,0 +1,17 @@ +import { getWithTimeout, postWithTimeout } from '../_utils/ajax' +import { auth, basename } from '../_api/utils' + +export async function getFollowRequests (instanceName, accessToken) { + let url = `${basename(instanceName)}/api/v1/follow_requests` + return getWithTimeout(url, auth(accessToken)) +} + +export async function authorizeFollowRequest (instanceName, accessToken, id) { + let url = `${basename(instanceName)}/api/v1/follow_requests/${id}/authorize` + return postWithTimeout(url, null, auth(accessToken)) +} + +export async function rejectFollowRequest (instanceName, accessToken, id) { + let url = `${basename(instanceName)}/api/v1/follow_requests/${id}/reject` + return postWithTimeout(url, null, auth(accessToken)) +} diff --git a/routes/_actions/timeline.js b/routes/_actions/timeline.js index 05b06e6..2bdce46 100644 --- a/routes/_actions/timeline.js +++ b/routes/_actions/timeline.js @@ -40,10 +40,10 @@ async function addTimelineItems (instanceName, timelineName, items, stale) { } export async function addTimelineItemIds (instanceName, timelineName, newIds, newStale) { - let oldIds = store.getForTimeline(instanceName, timelineName, 'timelineItemIds') || [] + let oldIds = store.getForTimeline(instanceName, timelineName, 'timelineItemIds') let oldStale = store.getForTimeline(instanceName, timelineName, 'timelineItemIdsAreStale') - let mergedIds = mergeArrays(oldIds, newIds) + let mergedIds = mergeArrays(oldIds || [], newIds) if (!isEqual(oldIds, mergedIds)) { store.setForTimeline(instanceName, timelineName, {timelineItemIds: mergedIds}) diff --git a/routes/_components/AccountProfile.html b/routes/_components/AccountProfile.html index a942ff5..8568e1c 100644 --- a/routes/_components/AccountProfile.html +++ b/routes/_components/AccountProfile.html @@ -24,8 +24,8 @@
{{#if verifyCredentials && relationship && verifyCredentials.id !== relationship.id}} relationship && relationship.following + following: (relationship) => relationship && relationship.following, + followRequested: (relationship) => relationship && relationship.requested, + followLabel: (following, followRequested) => { + if (following) { + return 'Unfollow' + } else if (followRequested) { + return 'Unfollow (follow requested)' + } else { + return 'Follow' + } + }, + followIcon: (following, followRequested) => { + if (following) { + return '#fa-user-times' + } else if (followRequested) { + return '#fa-hourglass' + } else { + return '#fa-user-plus' + } + } }, methods: { async onFollowButtonClick() { let accountId = this.get('profile').id let instanceName = this.store.get('currentInstance') let following = this.get('following') - await setAccountFollowed(accountId, !following) + let followRequested = this.get('followRequested') + await setAccountFollowed(accountId, !(following || followRequested)) this.set({relationship: await database.getRelationship(instanceName, accountId)}) } }, diff --git a/routes/_components/dialog/StatusOptionsDialog.html b/routes/_components/dialog/StatusOptionsDialog.html index 1a4efac..75f5f20 100644 --- a/routes/_components/dialog/StatusOptionsDialog.html +++ b/routes/_components/dialog/StatusOptionsDialog.html @@ -14,22 +14,25 @@ export default { account: ($currentAccountProfile) => $currentAccountProfile, verifyCredentials: ($currentVerifyCredentials) => $currentVerifyCredentials, verifyCredentialsId: (verifyCredentials) => verifyCredentials.id, - following: (relationship) => relationship && !!relationship.following, + following: (relationship) => relationship && relationship.following, + followRequested: (relationship) => relationship && relationship.requested, accountName: (account) => account && (account.display_name || account.acct), accountId: (account) => account && account.id, - followLabel: (following, accountName) => { + followLabel: (following, followRequested, accountName) => { if (typeof following === 'undefined' || !accountName) { return '' } - return following ? `Unfollow ${accountName}` : `Follow ${accountName}` + return (following || followRequested) + ? `Unfollow ${accountName}` + : `Follow ${accountName}` }, - items: (followLabel, following, accountId, verifyCredentialsId) => ( + items: (followLabel, following, followRequested, accountId, verifyCredentialsId) => ( [ accountId !== verifyCredentialsId && { key: 'follow', label: followLabel, - icon: following ? '#fa-user-times' : '#fa-user-plus' + icon: following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus' }, accountId === verifyCredentialsId && { diff --git a/routes/accounts/[accountId].html b/routes/accounts/[accountId].html index b552dad..dc7b3a2 100644 --- a/routes/accounts/[accountId].html +++ b/routes/accounts/[accountId].html @@ -1,5 +1,5 @@ <:Head> - Pinafore – {{profileName}} + Pinafore – Profile diff --git a/routes/lists/[listId].html b/routes/lists/[listId].html index b7b5336..74d1de6 100644 --- a/routes/lists/[listId].html +++ b/routes/lists/[listId].html @@ -1,5 +1,5 @@ <:Head> - Pinafore – {{listTitle}} + Pinafore – List diff --git a/routes/settings/instances/[instanceName].html b/routes/settings/instances/[instanceName].html index e978e57..e277503 100644 --- a/routes/settings/instances/[instanceName].html +++ b/routes/settings/instances/[instanceName].html @@ -1,5 +1,5 @@ <:Head> - Pinafore – {{params.instanceName}} + Pinafore – Instance diff --git a/routes/tags/[tagName].html b/routes/tags/[tagName].html index 8e99862..77f15d6 100644 --- a/routes/tags/[tagName].html +++ b/routes/tags/[tagName].html @@ -1,5 +1,5 @@ <:Head> - Pinafore – #{{params.tagName}} + Pinafore – Hashtag diff --git a/templates/2xx.html b/templates/2xx.html index 1d8a134..91a3b17 100644 --- a/templates/2xx.html +++ b/templates/2xx.html @@ -96,6 +96,7 @@ body.offline,body.theme-hotpants.offline,body.theme-majesty.offline,body.theme-o Content warning Check Delete +Follow requested