File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
apps/frontend/src/components/new-launch/providers/mastodon
libraries/nestjs-libraries/src/integrations/social Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -11,5 +11,9 @@ export default withProvider({
1111 CustomPreviewComponent : undefined ,
1212 dto : undefined ,
1313 checkValidity : undefined ,
14- maximumCharacters : 500 ,
14+ maximumCharacters : ( settings ) => {
15+ const value = settings ?. find ( ( s : any ) => s ?. title === 'Max characters' ) ?. value ;
16+ const parsed = Number ( value ) ;
17+ return Number . isFinite ( parsed ) && parsed > 0 ? parsed : 500 ;
18+ } ,
1519} ) ;
Original file line number Diff line number Diff line change @@ -89,6 +89,19 @@ export class MastodonProvider extends SocialAbstract implements SocialProvider {
8989 } )
9090 ) . json ( ) ;
9191
92+ let maxCharacters = 500 ;
93+ try {
94+ const instanceInfo = await (
95+ await this . fetch ( `${ url } /api/v1/instance` , {
96+ method : 'GET' ,
97+ } )
98+ ) . json ( ) ;
99+ maxCharacters =
100+ instanceInfo ?. configuration ?. statuses ?. max_characters ?? 500 ;
101+ } catch {
102+ // Keep default maxCharacters = 500 on failure
103+ }
104+
92105 return {
93106 id : personalInformation . id ,
94107 name : personalInformation . display_name || personalInformation . acct ,
@@ -97,6 +110,14 @@ export class MastodonProvider extends SocialAbstract implements SocialProvider {
97110 expiresIn : dayjs ( ) . add ( 100 , 'years' ) . unix ( ) - dayjs ( ) . unix ( ) ,
98111 picture : personalInformation ?. avatar || '' ,
99112 username : personalInformation . username ,
113+ additionalSettings : [
114+ {
115+ title : 'Max characters' ,
116+ description : 'Maximum characters per post for this instance' ,
117+ type : 'text' as const ,
118+ value : maxCharacters ,
119+ } ,
120+ ] ,
100121 } ;
101122 }
102123
You can’t perform that action at this time.
0 commit comments