84 lines
3.4 KiB
JavaScript
84 lines
3.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.buildCustomJsonOperation = buildCustomJsonOperation;
|
|
exports.buildFollowOperation = buildFollowOperation;
|
|
exports.buildUnfollowOperation = buildUnfollowOperation;
|
|
exports.buildMuteOperation = buildMuteOperation;
|
|
exports.buildUnmuteOperation = buildUnmuteOperation;
|
|
exports.buildReblogOperation = buildReblogOperation;
|
|
exports.buildUndoReblogOperation = buildUndoReblogOperation;
|
|
exports.buildCommunitySubscribeOperation = buildCommunitySubscribeOperation;
|
|
exports.buildCommunityUnsubscribeOperation = buildCommunityUnsubscribeOperation;
|
|
exports.buildReadNotificationOperation = buildReadNotificationOperation;
|
|
/** Build a typed `custom_json` operation from an unstringified payload. */
|
|
function buildCustomJsonOperation(options) {
|
|
return ['custom_json', {
|
|
id: options.id,
|
|
json: JSON.stringify(options.payload),
|
|
required_auths: options.required_auths || [],
|
|
required_posting_auths: options.required_posting_auths || [options.account]
|
|
}];
|
|
}
|
|
function buildFollowLikeOperation(options, what) {
|
|
return buildCustomJsonOperation({
|
|
account: options.follower,
|
|
id: 'follow',
|
|
payload: ['follow', { follower: options.follower, following: options.following, what }]
|
|
});
|
|
}
|
|
/** Build a `follow` custom_json operation using posting authority. */
|
|
function buildFollowOperation(options) {
|
|
return buildFollowLikeOperation(options, ['blog']);
|
|
}
|
|
/** Build an `unfollow` custom_json operation using the empty follow-list convention. */
|
|
function buildUnfollowOperation(options) {
|
|
return buildFollowLikeOperation(options, []);
|
|
}
|
|
/** Build a mute operation using the follow/ignore convention. */
|
|
function buildMuteOperation(options) {
|
|
return buildFollowLikeOperation(options, ['ignore']);
|
|
}
|
|
/** Build an unmute operation using the empty follow-list convention. */
|
|
function buildUnmuteOperation(options) {
|
|
return buildFollowLikeOperation(options, []);
|
|
}
|
|
/** Build a reblog custom_json operation. */
|
|
function buildReblogOperation(options) {
|
|
return buildCustomJsonOperation({
|
|
account: options.account,
|
|
id: 'reblog',
|
|
payload: ['reblog', { account: options.account, author: options.author, permlink: options.permlink }]
|
|
});
|
|
}
|
|
/** Build an undo-reblog custom_json operation. */
|
|
function buildUndoReblogOperation(options) {
|
|
return buildCustomJsonOperation({
|
|
account: options.account,
|
|
id: 'reblog',
|
|
payload: ['reblog', { account: options.account, author: options.author, permlink: options.permlink, delete: 'delete' }]
|
|
});
|
|
}
|
|
/** Build a community subscribe custom_json operation. */
|
|
function buildCommunitySubscribeOperation(options) {
|
|
return buildCustomJsonOperation({
|
|
account: options.account,
|
|
id: 'community',
|
|
payload: ['subscribe', { community: options.community }]
|
|
});
|
|
}
|
|
/** Build a community unsubscribe custom_json operation. */
|
|
function buildCommunityUnsubscribeOperation(options) {
|
|
return buildCustomJsonOperation({
|
|
account: options.account,
|
|
id: 'community',
|
|
payload: ['unsubscribe', { community: options.community }]
|
|
});
|
|
}
|
|
/** Build a notification read-marker custom_json operation. */
|
|
function buildReadNotificationOperation(options) {
|
|
return buildCustomJsonOperation({
|
|
account: options.account,
|
|
id: 'notify',
|
|
payload: ['setLastRead', { date: options.date }]
|
|
});
|
|
}
|