Allow clients to add mentions to a post
This commit is contained in:
parent
5676d53cbb
commit
05205c398e
3 changed files with 34 additions and 3 deletions
|
@ -295,6 +295,12 @@ paths:
|
||||||
enum:
|
enum:
|
||||||
- public
|
- public
|
||||||
- direct
|
- direct
|
||||||
|
mentions:
|
||||||
|
description: Array of profile IDs to be mentioned
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
required:
|
required:
|
||||||
- status
|
- status
|
||||||
responses:
|
responses:
|
||||||
|
@ -505,6 +511,21 @@ components:
|
||||||
description: Ethereum wallet address.
|
description: Ethereum wallet address.
|
||||||
type: string
|
type: string
|
||||||
example: '0xd8da6bf...'
|
example: '0xd8da6bf...'
|
||||||
|
Mention:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
description: The profile ID of the mentioned user.
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
username:
|
||||||
|
description: The username of the mentioned user.
|
||||||
|
type: string
|
||||||
|
acct:
|
||||||
|
type: string
|
||||||
|
url:
|
||||||
|
description: The location of the mentioned user's profile.
|
||||||
|
type: string
|
||||||
Notification:
|
Notification:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -561,6 +582,11 @@ components:
|
||||||
enum:
|
enum:
|
||||||
- public
|
- public
|
||||||
- direct
|
- direct
|
||||||
|
mentions:
|
||||||
|
description: Mentions of users within the post.
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Mention'
|
||||||
tags:
|
tags:
|
||||||
description: Hashtags used within the status content.
|
description: Hashtags used within the status content.
|
||||||
type: array
|
type: array
|
||||||
|
|
|
@ -132,6 +132,9 @@ pub struct StatusData {
|
||||||
|
|
||||||
pub in_reply_to_id: Option<Uuid>,
|
pub in_reply_to_id: Option<Uuid>,
|
||||||
pub visibility: Option<String>,
|
pub visibility: Option<String>,
|
||||||
|
|
||||||
|
// Not supported by Mastodon
|
||||||
|
pub mentions: Option<Vec<Uuid>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<StatusData> for PostCreateData {
|
impl TryFrom<StatusData> for PostCreateData {
|
||||||
|
@ -151,7 +154,7 @@ impl TryFrom<StatusData> for PostCreateData {
|
||||||
repost_of_id: None,
|
repost_of_id: None,
|
||||||
visibility: visibility,
|
visibility: visibility,
|
||||||
attachments: value.media_ids.unwrap_or(vec![]),
|
attachments: value.media_ids.unwrap_or(vec![]),
|
||||||
mentions: vec![],
|
mentions: value.mentions.unwrap_or(vec![]),
|
||||||
tags: vec![],
|
tags: vec![],
|
||||||
object_id: None,
|
object_id: None,
|
||||||
created_at: None,
|
created_at: None,
|
||||||
|
|
|
@ -75,8 +75,10 @@ async fn create_status(
|
||||||
&instance.url(),
|
&instance.url(),
|
||||||
&post_data.content,
|
&post_data.content,
|
||||||
);
|
);
|
||||||
post_data.mentions = mention_map.values()
|
post_data.mentions.extend(mention_map.values()
|
||||||
.map(|profile| profile.id).collect();
|
.map(|profile| profile.id));
|
||||||
|
post_data.mentions.sort();
|
||||||
|
post_data.mentions.dedup();
|
||||||
// Tags
|
// Tags
|
||||||
post_data.tags = find_tags(&post_data.content);
|
post_data.tags = find_tags(&post_data.content);
|
||||||
post_data.content = replace_tags(
|
post_data.content = replace_tags(
|
||||||
|
|
Loading…
Reference in a new issue