@@ -65,7 +65,8 @@ macro_rules! construct_withheld_content {
6565 WithheldCode :: Blacklisted
6666 | WithheldCode :: Unverified
6767 | WithheldCode :: Unauthorised
68- | WithheldCode :: Unavailable => {
68+ | WithheldCode :: Unavailable
69+ | WithheldCode :: HistoryNotShared => {
6970 let content = CommonWithheldCodeContent {
7071 $room_id,
7172 $session_id,
@@ -84,7 +85,9 @@ macro_rules! construct_withheld_content {
8485 . into( ) ,
8586 ) )
8687 }
87- _ => unreachable!( "Can't create an unknown withheld code content" ) ,
88+ WithheldCode :: _Custom( _) => {
89+ unreachable!( "Can't create an unknown withheld code content" )
90+ }
8891 }
8992 } ;
9093}
@@ -180,6 +183,9 @@ pub enum MegolmV1AesSha2WithheldContent {
180183 Unauthorised ( Box < CommonWithheldCodeContent > ) ,
181184 /// The `m.unavailable` variant of the withheld code content.
182185 Unavailable ( Box < CommonWithheldCodeContent > ) ,
186+ /// The `m.history_not_shared` variant of the withheld code content (cf
187+ /// [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)).
188+ HistoryNotShared ( Box < CommonWithheldCodeContent > ) ,
183189 /// The `m.no_olm` variant of the withheld code content.
184190 NoOlm ( Box < NoOlmWithheldContent > ) ,
185191}
@@ -231,7 +237,10 @@ impl MegolmV1AesSha2WithheldContent {
231237 MegolmV1AesSha2WithheldContent :: BlackListed ( content)
232238 | MegolmV1AesSha2WithheldContent :: Unverified ( content)
233239 | MegolmV1AesSha2WithheldContent :: Unauthorised ( content)
234- | MegolmV1AesSha2WithheldContent :: Unavailable ( content) => Some ( & content. session_id ) ,
240+ | MegolmV1AesSha2WithheldContent :: Unavailable ( content)
241+ | MegolmV1AesSha2WithheldContent :: HistoryNotShared ( content) => {
242+ Some ( & content. session_id )
243+ }
235244 MegolmV1AesSha2WithheldContent :: NoOlm ( _) => None ,
236245 }
237246 }
@@ -242,7 +251,8 @@ impl MegolmV1AesSha2WithheldContent {
242251 MegolmV1AesSha2WithheldContent :: BlackListed ( content)
243252 | MegolmV1AesSha2WithheldContent :: Unverified ( content)
244253 | MegolmV1AesSha2WithheldContent :: Unauthorised ( content)
245- | MegolmV1AesSha2WithheldContent :: Unavailable ( content) => Some ( & content. room_id ) ,
254+ | MegolmV1AesSha2WithheldContent :: Unavailable ( content)
255+ | MegolmV1AesSha2WithheldContent :: HistoryNotShared ( content) => Some ( & content. room_id ) ,
246256 MegolmV1AesSha2WithheldContent :: NoOlm ( _) => None ,
247257 }
248258 }
@@ -254,6 +264,7 @@ impl MegolmV1AesSha2WithheldContent {
254264 MegolmV1AesSha2WithheldContent :: Unverified ( _) => WithheldCode :: Unverified ,
255265 MegolmV1AesSha2WithheldContent :: Unauthorised ( _) => WithheldCode :: Unauthorised ,
256266 MegolmV1AesSha2WithheldContent :: Unavailable ( _) => WithheldCode :: Unavailable ,
267+ MegolmV1AesSha2WithheldContent :: HistoryNotShared ( _) => WithheldCode :: HistoryNotShared ,
257268 MegolmV1AesSha2WithheldContent :: NoOlm ( _) => WithheldCode :: NoOlm ,
258269 }
259270 }
@@ -266,7 +277,10 @@ impl MegolmV1AesSha2WithheldContent {
266277 WithheldCode :: Unverified => Self :: Unverified ( content) ,
267278 WithheldCode :: Unauthorised => Self :: Unauthorised ( content) ,
268279 WithheldCode :: Unavailable => Self :: Unavailable ( content) ,
269- _ => unreachable ! ( "This constructor requires one of the common withheld codes" ) ,
280+ WithheldCode :: HistoryNotShared => Self :: HistoryNotShared ( content) ,
281+ WithheldCode :: NoOlm | WithheldCode :: _Custom( _) => {
282+ unreachable ! ( "This constructor requires one of the common withheld codes" )
283+ }
270284 }
271285 }
272286}
@@ -349,14 +363,15 @@ impl TryFrom<WithheldHelper> for RoomKeyWithheldContent {
349363 WithheldCode :: Blacklisted
350364 | WithheldCode :: Unverified
351365 | WithheldCode :: Unauthorised
352- | WithheldCode :: Unavailable => {
366+ | WithheldCode :: Unavailable
367+ | WithheldCode :: HistoryNotShared => {
353368 let content: CommonWithheldCodeContent = serde_json:: from_value ( value. other ) ?;
354369
355370 Self :: MegolmV1AesSha2 ( MegolmV1AesSha2WithheldContent :: from_code_and_content (
356371 value. code , content,
357372 ) )
358373 }
359- _ => unknown ( value) ?,
374+ WithheldCode :: _Custom ( _ ) => unknown ( value) ?,
360375 } ,
361376 #[ cfg( feature = "experimental-algorithms" ) ]
362377 EventEncryptionAlgorithm :: MegolmV2AesSha2 => match value. code {
@@ -367,14 +382,15 @@ impl TryFrom<WithheldHelper> for RoomKeyWithheldContent {
367382 WithheldCode :: Blacklisted
368383 | WithheldCode :: Unverified
369384 | WithheldCode :: Unauthorised
370- | WithheldCode :: Unavailable => {
385+ | WithheldCode :: Unavailable
386+ | WithheldCode :: HistoryNotShared => {
371387 let content: CommonWithheldCodeContent = serde_json:: from_value ( value. other ) ?;
372388
373389 Self :: MegolmV1AesSha2 ( MegolmV1AesSha2WithheldContent :: from_code_and_content (
374390 value. code , content,
375391 ) )
376392 }
377- _ => unknown ( value) ?,
393+ WithheldCode :: _Custom ( _ ) => unknown ( value) ?,
378394 } ,
379395 _ => unknown ( value) ?,
380396 } )
@@ -397,7 +413,8 @@ impl Serialize for RoomKeyWithheldContent {
397413 MegolmV1AesSha2WithheldContent :: BlackListed ( content)
398414 | MegolmV1AesSha2WithheldContent :: Unverified ( content)
399415 | MegolmV1AesSha2WithheldContent :: Unauthorised ( content)
400- | MegolmV1AesSha2WithheldContent :: Unavailable ( content) => WithheldHelper {
416+ | MegolmV1AesSha2WithheldContent :: Unavailable ( content)
417+ | MegolmV1AesSha2WithheldContent :: HistoryNotShared ( content) => WithheldHelper {
401418 algorithm,
402419 code,
403420 reason,
@@ -420,7 +437,8 @@ impl Serialize for RoomKeyWithheldContent {
420437 MegolmV1AesSha2WithheldContent :: BlackListed ( content)
421438 | MegolmV1AesSha2WithheldContent :: Unverified ( content)
422439 | MegolmV1AesSha2WithheldContent :: Unauthorised ( content)
423- | MegolmV1AesSha2WithheldContent :: Unavailable ( content) => WithheldHelper {
440+ | MegolmV1AesSha2WithheldContent :: Unavailable ( content)
441+ | MegolmV1AesSha2WithheldContent :: HistoryNotShared ( content) => WithheldHelper {
424442 algorithm,
425443 code,
426444 reason,
@@ -534,6 +552,7 @@ pub(super) mod tests {
534552 WithheldCode :: Blacklisted ,
535553 WithheldCode :: Unauthorised ,
536554 WithheldCode :: Unavailable ,
555+ WithheldCode :: HistoryNotShared ,
537556 ] ;
538557 for code in codes {
539558 let json = json ( & code) ;
0 commit comments