pl-fe: allow setting location for posts if supported by backend

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-01-25 10:35:01 +01:00
parent 12c6d8755b
commit 98e1c0077e
9 changed files with 177 additions and 18 deletions

View File

@ -18,23 +18,25 @@ import { tagSchema } from './tag';
import { translationSchema } from './translation';
import { datetimeSchema, filteredArray } from './utils';
const locationSchema = v.object({
name: v.fallback(v.string(), ''),
url: v.fallback(v.pipe(v.string(), v.url()), ''),
latitude: v.fallback(v.nullable(v.number()), null),
longitude: v.fallback(v.nullable(v.number()), null),
street: v.fallback(v.string(), ''),
postal_code: v.fallback(v.string(), ''),
locality: v.fallback(v.string(), ''),
region: v.fallback(v.string(), ''),
country: v.fallback(v.string(), ''),
});
const statusEventSchema = v.object({
name: v.fallback(v.string(), ''),
start_time: v.fallback(v.nullable(datetimeSchema), null),
end_time: v.fallback(v.nullable(datetimeSchema), null),
join_mode: v.fallback(v.nullable(v.picklist(['free', 'restricted', 'invite', 'external'])), null),
participants_count: v.fallback(v.number(), 0),
location: v.fallback(v.nullable(v.object({
name: v.fallback(v.string(), ''),
url: v.fallback(v.pipe(v.string(), v.url()), ''),
latitude: v.fallback(v.nullable(v.number()), null),
longitude: v.fallback(v.nullable(v.number()), null),
street: v.fallback(v.string(), ''),
postal_code: v.fallback(v.string(), ''),
locality: v.fallback(v.string(), ''),
region: v.fallback(v.string(), ''),
country: v.fallback(v.string(), ''),
})), null),
location: v.fallback(v.nullable(locationSchema), null),
join_state: v.fallback(v.nullable(v.picklist(['pending', 'reject', 'accept'])), null),
});
@ -112,6 +114,7 @@ const baseStatusSchema = v.object({
interaction_policy: interactionPolicySchema,
content_type: v.fallback(v.nullable(v.string()), null),
location: v.fallback(v.nullable(locationSchema), null),
});
const preprocess = (status: any) => {
@ -166,6 +169,7 @@ const preprocess = (status: any) => {
'event',
'translation',
'rss_feed',
'location',
])),
...(pick(status.friendica || {}, [
'dislikes_count',

View File

@ -1715,6 +1715,8 @@ const getFeatures = (instance: Instance) => {
*/
statusDislikes: v.software === FRIENDICA && gte(v.version, '2023.3.0'),
statusLocation: instance.api_versions['status_location.pleroma.pl-api'] >= 1,
/**
* @see GET /api/web/stories/v1/recent
* @see GET /api/web/stories/v1/viewers

View File

@ -97,6 +97,8 @@ interface CreateStatusOptionalParams {
*/
quote_approval_policy?: 'public' | 'followers' | 'nobody';
location_id?: string;
/**
* If set to true, this status will be "local only" and will NOT be federated beyond the local timeline(s). If set to false (default), this status will be federated to your followers beyond the local timeline(s).
*/