Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v0.6.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed May 4, 2016
2 parents 5c1386f + 33330ec commit 147d0f4
Show file tree
Hide file tree
Showing 17 changed files with 471 additions and 29 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Changes in Matrix iOS SDK in 0.6.7 (2016-05-04)
===============================================

Improvements:
* Presence: Manage the currently_active parameter.
* MXRestClient: Add API to reset the account password.
* Ability to report abuse
* Ability to ignore users

Changes in Matrix iOS SDK in 0.6.6 (2016-04-26)
===============================================

Expand Down
4 changes: 2 additions & 2 deletions MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.6.6"
s.version = "0.6.7"
s.summary = "The iOS SDK to build apps compatible with Matrix (http://www.matrix.org)"

s.description = <<-DESC
Expand All @@ -19,7 +19,7 @@ Pod::Spec.new do |s|

s.platform = :ios, "7.0"

s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.6" }
s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.7" }
s.source_files = "MatrixSDK", "MatrixSDK/**/*.{h,m}"
s.resources = "MatrixSDK/Data/Store/MXCoreDataStore/*.xcdatamodeld"

Expand Down
19 changes: 19 additions & 0 deletions MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,25 @@ FOUNDATION_EXPORT NSString *const kMXRoomDidUpdateUnreadNotification;
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Report an event in this room.
@param eventId the id of the event event.
@param score the metric to let the user rate the severity of the abuse.
It ranges from -100 “most offensive” to 0 “inoffensive”.
@param reason the redaction reason (optional).
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)reportEvent:(NSString*)eventId
score:(NSInteger)score
reason:(NSString*)reason
success:(void (^)())success
failure:(void (^)(NSError *error))failure;


#pragma mark - Events timeline
/**
Expand Down
9 changes: 9 additions & 0 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ - (MXHTTPOperation*)redactEvent:(NSString*)eventId
return [mxSession.matrixRestClient redactEvent:eventId inRoom:self.state.roomId reason:reason success:success failure:failure];
}

- (MXHTTPOperation *)reportEvent:(NSString *)eventId
score:(NSInteger)score
reason:(NSString *)reason
success:(void (^)())success
failure:(void (^)(NSError *))failure
{
return [mxSession.matrixRestClient reportEvent:eventId inRoom:self.state.roomId score:score reason:reason success:success failure:failure];
}


#pragma mark - Events timeline
- (MXEventTimeline*)timelineOnEvent:(NSString*)eventId;
Expand Down
8 changes: 8 additions & 0 deletions MatrixSDK/Data/MXUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,17 @@
/**
The time since the last activity by the user.
This value in milliseconds is recomputed at each property reading.
It is NOT accurate if currentlyActive is YES.
Zero means unknown.
*/
@property (nonatomic, readonly) NSUInteger lastActiveAgo;

/**
Whether the user is currently active.
If YES, lastActiveAgo is an approximation and "Now" should be shown instead.
*/
@property (nonatomic, readonly) BOOL currentlyActive;

/**
Create an instance for an user ID.
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/Data/MXUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ - (void)updateWithPresenceEvent:(MXEvent*)presenceEvent
_presence = presenceContent.presenceStatus;

lastActiveLocalTS = [[NSDate date] timeIntervalSince1970] * 1000 - presenceContent.lastActiveAgo;
_currentlyActive = presenceContent.currentlyActive;

[self notifyListeners:presenceEvent];
}
Expand Down
16 changes: 15 additions & 1 deletion MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#import "MXFileStoreMetaData.h"

NSUInteger const kMXFileVersion = 24;
NSUInteger const kMXFileVersion = 25;

NSString *const kMXFileStoreFolder = @"MXFileStore";
NSString *const kMXFileStoreMedaDataFile = @"MXFileStore";
Expand Down Expand Up @@ -535,6 +535,20 @@ - (NSString *)userAvatarUrl
return metaData.userAvatarUrl;
}

- (void)setUserAccountData:(NSDictionary *)userAccountData
{
if (metaData)
{
metaData.userAccountData = userAccountData;
metaDataHasChanged = YES;
}
}

- (NSDictionary *)userAccountData
{
return metaData.userAccountData;
}

- (void)commit
{
// Save data only if metaData exists
Expand Down
5 changes: 5 additions & 0 deletions MatrixSDK/Data/Store/MXFileStore/MXFileStoreMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@
@property (nonatomic) NSString *userDisplayName;
@property (nonatomic) NSString *userAvatarUrl;

/**
User account data
*/
@property (nonatomic) NSDictionary *userAccountData;

@end
6 changes: 6 additions & 0 deletions MatrixSDK/Data/Store/MXFileStore/MXFileStoreMetaData.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder
_eventStreamToken = dict[@"eventStreamToken"];
_userDisplayName = dict[@"userDisplayName"];
_userAvatarUrl = dict[@"userAvatarUrl"];
_userAccountData = dict[@"userAccountData"];

NSNumber *version = dict[@"version"];
_version = [version unsignedIntegerValue];
Expand Down Expand Up @@ -60,6 +61,10 @@ -(void)encodeWithCoder:(NSCoder *)aCoder
{
dict[@"userAvatarUrl"] = _userAvatarUrl;
}
if (_userAccountData)
{
dict[@"userAccountData"] = _userAccountData;
}

[aCoder encodeObject:dict forKey:@"dict"];
}
Expand All @@ -75,6 +80,7 @@ - (id)copyWithZone:(NSZone *)zone
metaData->_eventStreamToken = [_eventStreamToken copyWithZone:zone];
metaData->_userDisplayName = [_userDisplayName copyWithZone:zone];
metaData->_userAvatarUrl = [_userAvatarUrl copyWithZone:zone];
metaData->_userAccountData = [_userAccountData copyWithZone:zone];

return metaData;
}
Expand Down
5 changes: 5 additions & 0 deletions MatrixSDK/Data/Store/MXStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,9 @@
*/
@property (nonatomic) NSString *userAvatarUrl;

/**
Store/retrieve the user account data.
*/
@property (nonatomic) NSDictionary *userAccountData;

@end
19 changes: 14 additions & 5 deletions MatrixSDK/JSONModels/MXJSONModels.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,7 @@ typedef enum : NSUInteger
MXPresenceUnknown, // The home server did not provide the information
MXPresenceOnline,
MXPresenceUnavailable,
MXPresenceOffline,
MXPresenceFreeForChat,
MXPresenceHidden
MXPresenceOffline
} MXPresence;

/**
Expand All @@ -353,8 +351,6 @@ typedef NSString* MXPresenceString;
FOUNDATION_EXPORT NSString *const kMXPresenceOnline;
FOUNDATION_EXPORT NSString *const kMXPresenceUnavailable;
FOUNDATION_EXPORT NSString *const kMXPresenceOffline;
FOUNDATION_EXPORT NSString *const kMXPresenceFreeForChat;
FOUNDATION_EXPORT NSString *const kMXPresenceHidden;

/**
`MXPresenceEventContent` represents the content of a presence event.
Expand All @@ -378,9 +374,17 @@ FOUNDATION_EXPORT NSString *const kMXPresenceHidden;

/**
The timestamp of the last time the user has been active.
It is NOT accurate if self.currentlyActive is YES.
Zero means unknown.
*/
@property (nonatomic) NSUInteger lastActiveAgo;

/**
Whether the user is currently active.
If YES, lastActiveAgo is an approximation and "Now" should be shown instead.
*/
@property (nonatomic) BOOL currentlyActive;

/**
The presence status string as provided by the home server.
*/
Expand Down Expand Up @@ -1124,6 +1128,11 @@ FOUNDATION_EXPORT NSString *const kMXPushRuleScopeStringDevice;
*/
@interface MXSyncResponse : MXJSONModel

/**
The user private data.
*/
@property (nonatomic) NSDictionary *accountData;

/**
The opaque token for the end.
*/
Expand Down
9 changes: 6 additions & 3 deletions MatrixSDK/JSONModels/MXJSONModels.m
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ - (NSString *)description
NSString *const kMXPresenceOnline = @"online";
NSString *const kMXPresenceUnavailable = @"unavailable";
NSString *const kMXPresenceOffline = @"offline";
NSString *const kMXPresenceFreeForChat = @"free_for_chat";
NSString *const kMXPresenceHidden = @"hidden";

@implementation MXPresenceEventContent

Expand All @@ -384,7 +382,11 @@ + (id)modelFromJSON:(NSDictionary *)JSONDictionary
MXJSONModelSetUInteger(presenceEventContent.lastActiveAgo, JSONDictionary[@"last_active_ago"]);
MXJSONModelSetString(presenceEventContent.presence, JSONDictionary[@"presence"]);
MXJSONModelSetString(presenceEventContent.statusMsg, JSONDictionary[@"status_msg"]);

if (JSONDictionary[@"currently_active"])
{
MXJSONModelSetBoolean(presenceEventContent.currentlyActive, JSONDictionary[@"currently_active"]);
}

presenceEventContent.presenceStatus = [MXTools presence:presenceEventContent.presence];
}
return presenceEventContent;
Expand Down Expand Up @@ -1020,6 +1022,7 @@ + (id)modelFromJSON:(NSDictionary *)JSONDictionary
MXSyncResponse *syncResponse = [[MXSyncResponse alloc] init];
if (syncResponse)
{
MXJSONModelSetDictionary(syncResponse.accountData, JSONDictionary[@"account_data"])
MXJSONModelSetString(syncResponse.nextBatch, JSONDictionary[@"next_batch"]);
MXJSONModelSetMXJSONModel(syncResponse.presence, MXPresenceSyncResponse, JSONDictionary[@"presence"]);
MXJSONModelSetMXJSONModel(syncResponse.rooms, MXRoomsSyncResponse, JSONDictionary[@"rooms"]);
Expand Down
63 changes: 63 additions & 0 deletions MatrixSDK/MXRestClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ typedef NSString* MXRoomVisibility;
FOUNDATION_EXPORT NSString *const kMXRoomVisibilityPublic;
FOUNDATION_EXPORT NSString *const kMXRoomVisibilityPrivate;

/**
Account data types
*/
FOUNDATION_EXPORT NSString *const kMXAccountDataTypeIgnoredUserList;

/**
Account data keys
*/
FOUNDATION_EXPORT NSString *const kMXAccountDataKeyIgnoredUser;

/**
MXRestClient error domain
*/
Expand Down Expand Up @@ -271,6 +281,19 @@ typedef enum : NSUInteger
*/
- (NSString*)loginFallback;

/**
Reset the account password.
@param parameters a set of parameters containing a threepid credentials and the new password.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)resetPasswordWithParameters:(NSDictionary*)parameters
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Replace the account password.
Expand All @@ -285,6 +308,25 @@ typedef enum : NSUInteger
success:(void (^)())success
failure:(void (^)(NSError *error))failure;


#pragma mark - Account data
/**
Set some account_data for the client.
@param data the new data to set for this event type.
@param type The event type of the account_data to set (@see kMXAccountDataType* strings)
Custom types should be namespaced to avoid clashes.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)setAccountData:(NSDictionary*)data
forType:(NSString*)type
success:(void (^)())success
failure:(void (^)(NSError *error))failure;


#pragma mark - Push Notifications
/**
Update the pusher for this device on the Home Server.
Expand Down Expand Up @@ -779,6 +821,27 @@ typedef enum : NSUInteger
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Report an event.
@param eventId the id of the event event.
@param roomId the id of the room.
@param score the metric to let the user rate the severity of the abuse.
It ranges from -100 “most offensive” to 0 “inoffensive”.
@param reason the redaction reason (optional).
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)reportEvent:(NSString*)eventId
inRoom:(NSString*)roomId
score:(NSInteger)score
reason:(NSString*)reason
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Get all the current information for this room, including messages and state events.
Expand Down
Loading

0 comments on commit 147d0f4

Please sign in to comment.