Skip to content

Commit

Permalink
element-hq/element-ios/issues/5298 - Using MXEventAssetTypeUser as de…
Browse files Browse the repository at this point in the history
…fault as per the MSC.
  • Loading branch information
stefanceriu committed Jan 19, 2022
1 parent cfdac87 commit 3f8db87
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions MatrixSDK/JSONModels/Event/Content/MXEventContentLocation.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,46 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary
{
NSString *description;
NSString *geoURIString;
MXEventAssetType assetType = MXEventAssetTypeGeneric;
MXEventAssetType assetType = MXEventAssetTypeUser;

NSDictionary *locationDictionary = JSONDictionary[kMXMessageContentKeyExtensibleLocationMSC3488];
if (locationDictionary == nil)
{
locationDictionary = JSONDictionary[kMXMessageContentKeyExtensibleLocation];
}

if (locationDictionary) {
if (locationDictionary)
{
MXJSONModelSetString(geoURIString, locationDictionary[kMXMessageContentKeyExtensibleLocationURI]);
MXJSONModelSetString(description, locationDictionary[kMXMessageContentKeyExtensibleLocationDescription]);
} else if ([JSONDictionary[kMXMessageTypeKey] isEqualToString:kMXMessageTypeLocation]) {
}
else if ([JSONDictionary[kMXMessageTypeKey] isEqualToString:kMXMessageTypeLocation])
{
MXJSONModelSetString(geoURIString, JSONDictionary[kMXMessageGeoURIKey]);
} else {
}
else
{
return nil;
}

if ([JSONDictionary[kMXMessageContentKeyExtensibleAsset][kMXMessageContentKeyExtensibleAssetType] isEqualToString:kMXMessageContentKeyExtensibleAssetTypeUser] ||
[JSONDictionary[kMXMessageContentKeyExtensibleAssetMSC3488][kMXMessageContentKeyExtensibleAssetType] isEqualToString:kMXMessageContentKeyExtensibleAssetTypeUser])
NSDictionary *assetDictionary = JSONDictionary[kMXMessageContentKeyExtensibleAssetMSC3488];
if (assetDictionary == nil)
{
assetType = MXEventAssetTypeUser;
assetDictionary = JSONDictionary[kMXMessageContentKeyExtensibleAsset];
}

if (assetDictionary)
{
if (![assetDictionary[kMXMessageContentKeyExtensibleAssetType] isEqualToString:kMXMessageContentKeyExtensibleAssetTypeUser]) {
assetType = MXEventAssetTypeGeneric;
}
}

NSString *locationString = [[geoURIString componentsSeparatedByString:@":"].lastObject componentsSeparatedByString:@";"].firstObject;
NSArray *locationComponents = [locationString componentsSeparatedByString:@","];

if (locationComponents.count != 2) {
if (locationComponents.count != 2)
{
return nil;
}

Expand Down

0 comments on commit 3f8db87

Please sign in to comment.