Pleroma: status interaction support

This commit is contained in:
Austin Huang 2023-02-26 22:25:20 -05:00
parent d1c09e501a
commit a92434d3da
No known key found for this signature in database
GPG key ID: 84C23AA04587A91F
2 changed files with 10 additions and 5 deletions

View file

@ -135,7 +135,7 @@ async function handleError(error) {
function getInteractionType(url) {
for (const fedType of Object.values(FEDIVERSE_TYPE)) {
for (const [checkRegEx, interactionType] of FEDIVERSE_MODULE[fedType].CATCH_URLS) {
if (url.pathname.match(checkRegEx)) {
if (url.href.match(checkRegEx)) {
return [fedType, interactionType];
}
}

View file

@ -5,7 +5,6 @@
*/
import * as NetworkTools from "/common/modules/NetworkTools.js";
import {NotSupportedError} from "/common/modules/Errors.js";
import {INTERACTION_TYPE} from "../data/INTERACTION_TYPE.js";
import isString from "/common/modules/lodash/isString.js";
@ -13,9 +12,12 @@ import isString from "/common/modules/lodash/isString.js";
const REMOTE_FOLLOW_REGEX = /\/main\/ostatus\/?$/;
// https://regex101.com/r/fjPdgC/1
const USER_PAGE_URL_REGEX = /\/users\/(.+)\/?$/;
// really just REMOTE_FOLLOW_REGEX with status_id query
const REMOTE_INTERACT_REGEX = /\/main\/ostatus\/?\?status_id=\w+$/;
/** The URLs to intercept and pass to this module. */
export const CATCH_URLS = new Map();
CATCH_URLS.set(REMOTE_INTERACT_REGEX, INTERACTION_TYPE.TOOT_INTERACT);
CATCH_URLS.set(REMOTE_FOLLOW_REGEX, INTERACTION_TYPE.FOLLOW);
/**
@ -84,13 +86,16 @@ export function getTabToModify(requestDetails) {
}
/**
* Find the follow URL.
* Find the status URL.
*
* @public
* @param {URL} url
* @returns {Promise}
*/
export function getTootUrl() {
throw new NotSupportedError("getTootUrl() is not supported");
export function getTootUrl(url) {
return new Promise((resolve, reject) => {
resolve("https://" + url.host + "/notice/" + url.searchParams.get("status_id"));
});
}
/**