File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,22 @@ describe("normalizeForwardedContext", () => {
169169 expect ( ctx ?. from ) . toBe ( "My Channel (New Sig)" ) ;
170170 } ) ;
171171
172+ it ( "returns undefined signature when author_signature is blank" , ( ) => {
173+ const ctx = normalizeForwardedContext ( {
174+ forward_origin : {
175+ type : "channel" ,
176+ chat : { title : "Updates" , id : - 100333 , type : "channel" } ,
177+ date : 860 ,
178+ author_signature : " " ,
179+ message_id : 1 ,
180+ } ,
181+ // oxlint-disable-next-line typescript/no-explicit-any
182+ } as any ) ;
183+ expect ( ctx ) . not . toBeNull ( ) ;
184+ expect ( ctx ?. fromSignature ) . toBeUndefined ( ) ;
185+ expect ( ctx ?. from ) . toBe ( "Updates" ) ;
186+ } ) ;
187+
172188 it ( "handles forward_origin channel without author_signature" , ( ) => {
173189 const ctx = normalizeForwardedContext ( {
174190 forward_origin : {
Original file line number Diff line number Diff line change @@ -253,6 +253,8 @@ export function describeReplyTarget(msg: Message): TelegramReplyTarget | null {
253253 } ;
254254}
255255
256+ export type TelegramChatType = "private" | "group" | "supergroup" | "channel" ;
257+
256258export type TelegramForwardedContext = {
257259 from : string ;
258260 date ?: number ;
@@ -262,7 +264,7 @@ export type TelegramForwardedContext = {
262264 fromTitle ?: string ;
263265 fromSignature ?: string ;
264266 /** Original chat type from forward_from_chat (e.g. "channel", "supergroup", "group"). */
265- fromChatType ?: string ;
267+ fromChatType ?: TelegramChatType ;
266268 /** Original message ID in the source chat (channel forwards). */
267269 fromMessageId ?: number ;
268270} ;
@@ -336,7 +338,7 @@ function buildForwardedContextFromChat(params: {
336338 }
337339 const signature = params . signature ?. trim ( ) || undefined ;
338340 const from = signature ? `${ display } (${ signature } )` : display ;
339- const chatType = params . chat . type ?. trim ( ) || undefined ;
341+ const chatType = ( params . chat . type ?. trim ( ) || undefined ) as TelegramChatType | undefined ;
340342 return {
341343 from,
342344 date : params . date ,
You can’t perform that action at this time.
0 commit comments