Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MXMediaManager/MXMediaLoader: Do not allow non-mxc content URLs. #593

Merged
merged 10 commits into from
Nov 13, 2018

Conversation

giomfo
Copy link
Member

@giomfo giomfo commented Nov 11, 2018

Improvements:

  • MXMediaManager/MXMediaLoader: Do not allow non-mxc content URLs.
  • MXMediaManager: Add a constructor based on a homeserver URL, to handle directly the Matrix Content URI (mxc://...).
  • MXSession: Add a MediaManager instance to handle the media stored on the Matrix Content repository.

Bug Fix:

  • MXRestClient: [avatarUrlForUser:success:failure]: the returned url is always nil.

Deprecated API:

  • MXMediaManager: [downloadMediaFromURL:andSaveAtFilePath:success:failure:] is deprecated, use [downloadMediaFromMatrixContentURI:withType:inFolder:success:failure] or [downloadThumbnailFromMatrixContentURI:withType:inFolder:toFitViewSize:withMethod:success:failure] instead.
  • MXMediaManager: [downloadMediaFromURL:andSaveAtFilePath:] is deprecated, use [downloadMediaFromMatrixContentURI:withType:inFolder:] instead.
  • MXMediaManager: [existingDownloaderWithOutputFilePath:] is deprecated, use [existingDownloaderWithIdentifier:] instead.
  • MXMediaManager: [cachePathForMediaWithURL:andType:inFolder:] is deprecated, use [cachePathForMatrixContentURI:andType:inFolder:] instead.
  • MXMediaLoader: the notification names "kMXMediaDownloadxxx" and "kMXMediaUploadxxx" are deprecated, use kMXMediaLoaderStateDidChangeNotification instead.
  • MXMediaLoader: [downloadMediaFromURL:andSaveAtFilePath:success:failure] is deprecated, use [downloadMediaFromURL:withIdentifier:andSaveAtFilePath:success:failure] instead.
  • MXRestClient: [urlOfContent:] and [urlOfContentThumbnail:toFitViewSize:withMethod:] are deprecated.

API break:

  • The Matrix Content repository contants are moved to MXEnumConstants.h
  • [urlOfIdenticon:] is moved from MXRestClient to MXMediaManager.

- The Matrix Media Content repository contants are moved to MXEnumConstants.h
- MXSession: Add a MediaManager instance to handle directly the media stored on the Matrix Content repository.
- MediaManager: an instance is initialized with homeserver URL to be able to handle itself the Matrix Content URI (mxc://...).
- API break:  "- (NSString *)urlOfIdenticon:(NSString *)identiconString" is moved from MXRestClient to MXMediaManager.
- Replace all the set of notifications with only one notification based on state change
…ned url is nil

whatever the value returned by the server
Copy link
Contributor

@manuroe manuroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but could we remove all deprecated methods, please?
That will help to maintain it later.

@"info": [@{
@"thumbnail_url": fakeMediaManagerThumbnailURL,
@"thumbnail_url": fakeMediaURI,
@"thumbnail_info": @{
@"mimetype": @"image/jpeg",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR but that would be nice MIME type constants

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

/**
Statistics on the operation in progress.
- kMXMediaLoaderProgressValueKey: progress value in [0, 1] range (NSNumber object) [In case of upload, the properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for future: kMXMediaLoaderProgressValueKey, kMXMediaLoaderProgressValueKey and kMXMediaLoaderTotalBytesCountKey values could all fit a NSProgress object.
kMXMediaLoaderCurrentDataRateKey could even be stored as userInfo of this NSProgress object.

MatrixSDK/Utils/Media/MXMediaLoader.h Outdated Show resolved Hide resolved
And increase MediaCacheSdkVersion
@giomfo giomfo merged commit c524a2a into develop Nov 13, 2018
@giomfo giomfo deleted the media_refacto branch November 13, 2018 16:42
giomfo added a commit to tchapgouv/tchap-ios that referenced this pull request Nov 14, 2018
Improvements:
 * Replace the deprecated MXMediaManager and MXMediaLoader interfaces use (see matrix-org/matrix-ios-sdk/pull/593).
 * Replace the deprecated MXKAttachment and MXKImageView interfaces use (see matrix-org/matrix-ios-kit/pull/487).
 * Server Quota Notices: Implement the blue banner (1937).
 * Lazy loading: Enable it by default (if the homeserver supports it).
 * i18n: Add Spanish (sp).
 * Settings: Make advanced info copyable (2023).
 * Settings: Made cryptography info copyable, thanks to @daverPL (PR 1999).

Bug fix:
 * Notifications: old notifications can reappear (1985).
 * Fix missing read receipts when lazy-loading room members.
 * Weird text color when selecting a message (2046).
 * Fix input toolbar reset in RoomViewController on MXSession state change (2006 and 2008).
 * User defaults: the preset application language (if any) is ignored.
 * Recents: Avoid to open a room twice (it crashed on room creation on quick HSes).
 * Riot-bot: Do not try to create a room with it if the user homeserver is not federated.
 * Empty app if initial /sync fails (1975).
 * Fix possible race conditions in direct rooms management.
giomfo added a commit to tchapgouv/tchap-ios that referenced this pull request Nov 14, 2018
* Rebase onto vector-im/riot-ios:

Improvements:
 * Replace the deprecated MXMediaManager and MXMediaLoader interfaces use (see matrix-org/matrix-ios-sdk/pull/593).
 * Replace the deprecated MXKAttachment and MXKImageView interfaces use (see matrix-org/matrix-ios-kit/pull/487).
 * Server Quota Notices: Implement the blue banner (1937).
 * Lazy loading: Enable it by default (if the homeserver supports it).
 * i18n: Add Spanish (sp).
 * Settings: Make advanced info copyable (2023).
 * Settings: Made cryptography info copyable, thanks to @daverPL (PR 1999).

Bug fix:
 * Notifications: old notifications can reappear (1985).
 * Fix missing read receipts when lazy-loading room members.
 * Weird text color when selecting a message (2046).
 * Fix input toolbar reset in RoomViewController on MXSession state change (2006 and 2008).
 * User defaults: the preset application language (if any) is ignored.
 * Recents: Avoid to open a room twice (it crashed on room creation on quick HSes).
 * Riot-bot: Do not try to create a room with it if the user homeserver is not federated.
 * Empty app if initial /sync fails (1975).
 * Fix possible race conditions in direct rooms management.

- Remove deprecated MXKImageView interface use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants