Sfoglia il codice sorgente

content-dir: move category of channels and videos into metadata

Mokhtar Naamani 4 anni fa
parent
commit
a903a493d8

+ 6 - 0
content-metadata-protobuf/compiled/proto/Channel_pb.d.ts

@@ -34,6 +34,11 @@ export class ChannelMetadata extends jspb.Message {
   getAvatarPhoto(): number | undefined;
   setAvatarPhoto(value: number): void;
 
+  hasCategory(): boolean;
+  clearCategory(): void;
+  getCategory(): number | undefined;
+  setCategory(value: number): void;
+
   serializeBinary(): Uint8Array;
   toObject(includeInstance?: boolean): ChannelMetadata.AsObject;
   static toObject(includeInstance: boolean, msg: ChannelMetadata): ChannelMetadata.AsObject;
@@ -52,6 +57,7 @@ export namespace ChannelMetadata {
     language?: string,
     coverPhoto?: number,
     avatarPhoto?: number,
+    category?: number,
   }
 }
 

+ 49 - 1
content-metadata-protobuf/compiled/proto/Channel_pb.js

@@ -95,7 +95,8 @@ proto.ChannelMetadata.toObject = function(includeInstance, msg) {
     isPublic: (f = jspb.Message.getBooleanField(msg, 3)) == null ? undefined : f,
     language: (f = jspb.Message.getField(msg, 4)) == null ? undefined : f,
     coverPhoto: (f = jspb.Message.getField(msg, 5)) == null ? undefined : f,
-    avatarPhoto: (f = jspb.Message.getField(msg, 6)) == null ? undefined : f
+    avatarPhoto: (f = jspb.Message.getField(msg, 6)) == null ? undefined : f,
+    category: (f = jspb.Message.getField(msg, 7)) == null ? undefined : f
   };
 
   if (includeInstance) {
@@ -156,6 +157,10 @@ proto.ChannelMetadata.deserializeBinaryFromReader = function(msg, reader) {
       var value = /** @type {number} */ (reader.readUint32());
       msg.setAvatarPhoto(value);
       break;
+    case 7:
+      var value = /** @type {number} */ (reader.readUint64());
+      msg.setCategory(value);
+      break;
     default:
       reader.skipField();
       break;
@@ -227,6 +232,13 @@ proto.ChannelMetadata.serializeBinaryToWriter = function(message, writer) {
       f
     );
   }
+  f = /** @type {number} */ (jspb.Message.getField(message, 7));
+  if (f != null) {
+    writer.writeUint64(
+      7,
+      f
+    );
+  }
 };
 
 
@@ -446,6 +458,42 @@ proto.ChannelMetadata.prototype.hasAvatarPhoto = function() {
 };
 
 
+/**
+ * optional uint64 category = 7;
+ * @return {number}
+ */
+proto.ChannelMetadata.prototype.getCategory = function() {
+  return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 7, 0));
+};
+
+
+/**
+ * @param {number} value
+ * @return {!proto.ChannelMetadata} returns this
+ */
+proto.ChannelMetadata.prototype.setCategory = function(value) {
+  return jspb.Message.setField(this, 7, value);
+};
+
+
+/**
+ * Clears the field making it undefined.
+ * @return {!proto.ChannelMetadata} returns this
+ */
+proto.ChannelMetadata.prototype.clearCategory = function() {
+  return jspb.Message.setField(this, 7, undefined);
+};
+
+
+/**
+ * Returns whether this field is set.
+ * @return {boolean}
+ */
+proto.ChannelMetadata.prototype.hasCategory = function() {
+  return jspb.Message.getField(this, 7) != null;
+};
+
+
 
 
 

+ 6 - 0
content-metadata-protobuf/compiled/proto/Video_pb.d.ts

@@ -175,6 +175,11 @@ export class VideoMetadata extends jspb.Message {
   setPersonsList(value: Array<number>): void;
   addPersons(value: number, index?: number): number;
 
+  hasCategory(): boolean;
+  clearCategory(): void;
+  getCategory(): number | undefined;
+  setCategory(value: number): void;
+
   serializeBinary(): Uint8Array;
   toObject(includeInstance?: boolean): VideoMetadata.AsObject;
   static toObject(includeInstance: boolean, msg: VideoMetadata): VideoMetadata.AsObject;
@@ -202,6 +207,7 @@ export namespace VideoMetadata {
     isPublic?: boolean,
     isExplicit?: boolean,
     personsList: Array<number>,
+    category?: number,
   }
 }
 

+ 49 - 1
content-metadata-protobuf/compiled/proto/Video_pb.js

@@ -861,7 +861,8 @@ proto.VideoMetadata.toObject = function(includeInstance, msg) {
     hasMarketing: (f = jspb.Message.getBooleanField(msg, 12)) == null ? undefined : f,
     isPublic: (f = jspb.Message.getBooleanField(msg, 13)) == null ? undefined : f,
     isExplicit: (f = jspb.Message.getBooleanField(msg, 14)) == null ? undefined : f,
-    personsList: (f = jspb.Message.getRepeatedField(msg, 15)) == null ? undefined : f
+    personsList: (f = jspb.Message.getRepeatedField(msg, 15)) == null ? undefined : f,
+    category: (f = jspb.Message.getField(msg, 16)) == null ? undefined : f
   };
 
   if (includeInstance) {
@@ -963,6 +964,10 @@ proto.VideoMetadata.deserializeBinaryFromReader = function(msg, reader) {
         msg.addPersons(values[i]);
       }
       break;
+    case 16:
+      var value = /** @type {number} */ (reader.readUint64());
+      msg.setCategory(value);
+      break;
     default:
       reader.skipField();
       break;
@@ -1100,6 +1105,13 @@ proto.VideoMetadata.serializeBinaryToWriter = function(message, writer) {
       f
     );
   }
+  f = /** @type {number} */ (jspb.Message.getField(message, 16));
+  if (f != null) {
+    writer.writeUint64(
+      16,
+      f
+    );
+  }
 };
 
 
@@ -1647,6 +1659,42 @@ proto.VideoMetadata.prototype.clearPersonsList = function() {
 };
 
 
+/**
+ * optional uint64 category = 16;
+ * @return {number}
+ */
+proto.VideoMetadata.prototype.getCategory = function() {
+  return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 16, 0));
+};
+
+
+/**
+ * @param {number} value
+ * @return {!proto.VideoMetadata} returns this
+ */
+proto.VideoMetadata.prototype.setCategory = function(value) {
+  return jspb.Message.setField(this, 16, value);
+};
+
+
+/**
+ * Clears the field making it undefined.
+ * @return {!proto.VideoMetadata} returns this
+ */
+proto.VideoMetadata.prototype.clearCategory = function() {
+  return jspb.Message.setField(this, 16, undefined);
+};
+
+
+/**
+ * Returns whether this field is set.
+ * @return {boolean}
+ */
+proto.VideoMetadata.prototype.hasCategory = function() {
+  return jspb.Message.getField(this, 16) != null;
+};
+
+
 
 
 

+ 2 - 0
content-metadata-protobuf/doc/index.md

@@ -64,6 +64,7 @@
 | language | [string](#string) | optional | ISO_639-1 Language [Code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) |
 | cover_photo | [uint32](#uint32) | optional | index into external [assets array](#.Assets) |
 | avatar_photo | [uint32](#uint32) | optional | index into external [assets array](#.Assets) |
+| category | [uint64](#uint64) | optional | Channel Category Id |
 
 
 
@@ -293,6 +294,7 @@ Publication status before joystream
 | is_public | [bool](#bool) | optional | Should video be publicy visible yet |
 | is_explicit | [bool](#bool) | optional | Does Video have explicit language or scenes |
 | persons | [uint64](#uint64) | repeated | Person(s) referenced by PersonId involved in this video |
+| category | [uint64](#uint64) | optional | Video Category Id |
 
 
 

+ 3 - 0
content-metadata-protobuf/proto/Channel.proto

@@ -17,6 +17,9 @@ message ChannelMetadata {
     optional uint32 cover_photo = 5;
     // index into external [assets array](#.Assets)
     optional uint32 avatar_photo  = 6;
+
+    // Channel Category Id
+    optional uint64 category = 7;
 }
 
 message ChannelCategoryMetadata {

+ 3 - 0
content-metadata-protobuf/proto/Video.proto

@@ -77,6 +77,9 @@ message VideoMetadata {
 
     // Person(s) referenced by PersonId involved in this video
     repeated uint64 persons = 15 [packed=true];
+
+    // Video Category Id
+    optional uint64 category = 16;
 }
 
 message VideoCategoryMetadata {

+ 2 - 0
content-metadata-protobuf/test/channel.ts

@@ -16,6 +16,7 @@ describe('Channel Metadata', () => {
     channel.setLanguage(language)
     channel.setAvatarPhoto(0)
     channel.setCoverPhoto(1)
+    channel.setCategory(100)
 
     assert.deepEqual(channel.toObject(), {
       title,
@@ -24,6 +25,7 @@ describe('Channel Metadata', () => {
       language,
       avatarPhoto: 0,
       coverPhoto: 1,
+      category: 100,
     })
 
     assert.deepEqual(ChannelMetadata.deserializeBinary(channel.serializeBinary()), channel)

+ 2 - 0
content-metadata-protobuf/test/video.ts

@@ -23,6 +23,7 @@ describe('Video Metadata', () => {
     meta.setIsExplicit(false)
     meta.setVideo(0)
     meta.setThumbnailPhoto(1)
+    meta.setCategory(101)
 
     assert.deepEqual(meta.toObject(), {
       title,
@@ -48,6 +49,7 @@ describe('Video Metadata', () => {
       thumbnailPhoto: 1,
       video: 0,
       personsList: [],
+      category: 101,
     })
 
     // sanity check - encoding / decoding works

+ 24 - 65
runtime-modules/content/src/lib.rs

@@ -166,20 +166,10 @@ pub struct ChannelCategoryUpdateParameters {
 /// If a channel is deleted, all videos, playlists and series will also be deleted.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct ChannelRecord<
-    MemberId,
-    CuratorGroupId,
-    ChannelCategoryId,
-    DAOId,
-    AccountId,
-    VideoId,
-    PlaylistId,
-    SeriesId,
-> {
+pub struct ChannelRecord<MemberId, CuratorGroupId, DAOId, AccountId, VideoId, PlaylistId, SeriesId>
+{
     /// The owner of a channel
     owner: ChannelOwner<MemberId, CuratorGroupId, DAOId>,
-    /// The category the channel belongs to
-    in_category: ChannelCategoryId,
     /// The videos under this channel
     videos: Vec<VideoId>,
     /// The playlists under this channel
@@ -196,7 +186,6 @@ pub struct ChannelRecord<
 pub type Channel<T> = ChannelRecord<
     <T as MembershipTypes>::MemberId,
     <T as ContentActorAuthenticator>::CuratorGroupId,
-    <T as Trait>::ChannelCategoryId,
     <T as StorageOwnership>::DAOId,
     <T as system::Trait>::AccountId,
     <T as Trait>::VideoId,
@@ -231,9 +220,7 @@ pub type ChannelOwnershipTransferRequest<T> = ChannelOwnershipTransferRequestRec
 /// Information about channel being created.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct ChannelCreationParameters<ChannelCategoryId> {
-    /// ChannelCategory to enter the channel into.
-    in_category: ChannelCategoryId,
+pub struct ChannelCreationParameters {
     /// Metadata about the channel.
     meta: Vec<u8>,
 }
@@ -241,9 +228,7 @@ pub struct ChannelCreationParameters<ChannelCategoryId> {
 /// Information about channel being updated.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct ChannelUpdateParameters<ChannelCategoryId> {
-    /// If set, the new channel category to move the channel into.
-    new_in_category: Option<ChannelCategoryId>,
+pub struct ChannelUpdateParameters {
     /// If set, metadata update for the channel.
     new_meta: Option<Vec<u8>>,
 }
@@ -275,18 +260,14 @@ pub struct VideoCategoryUpdateParameters {
 /// Information about the video being created.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct VideoCreationParameters<VideoCategoryId> {
-    /// The video category the video belongs to.
-    in_category: VideoCategoryId,
+pub struct VideoCreationParameters {
     /// Metadata for the video.
     meta: Vec<u8>,
 }
 
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct VideoUpdateParameters<VideoCategoryId> {
-    /// If set, the new category the video should be moved into.
-    new_in_category: Option<VideoCategoryId>,
+pub struct VideoUpdateParameters {
     /// If set, metadata update for the video.
     new_meta: Option<Vec<u8>>,
 }
@@ -341,9 +322,9 @@ pub struct Playlist<ChannelId, VideoId> {
 /// Information about the episode being created or updated.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)]
-pub enum EpisodeParameters<VideoCategoryId, VideoId> {
+pub enum EpisodeParameters<VideoId> {
     /// A new video is being added as the episode.
-    NewVideo(VideoCreationParameters<VideoCategoryId>),
+    NewVideo(VideoCreationParameters),
     /// An existing video is being made into an episode.
     ExistingVideo(VideoId),
 }
@@ -351,13 +332,13 @@ pub enum EpisodeParameters<VideoCategoryId, VideoId> {
 /// Information about the season being created or updated.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct SeasonParameters<VideoCategoryId, VideoId> {
+pub struct SeasonParameters<VideoId> {
     // ?? It might just be more straighforward to always provide full list of episodes at cost of larger tx.
     /// If set, updates the episodes of a season. Extends the number of episodes in a season
     /// when length of new_episodes is greater than previously set. Last elements must all be
     /// 'Some' in that case.
     /// Will truncate existing season when length of new_episodes is less than previously set.
-    episodes: Option<Vec<Option<EpisodeParameters<VideoCategoryId, VideoId>>>>,
+    episodes: Option<Vec<Option<EpisodeParameters<VideoId>>>>,
     /// If set, Metadata update for season.
     meta: Option<Vec<u8>>,
 }
@@ -365,12 +346,12 @@ pub struct SeasonParameters<VideoCategoryId, VideoId> {
 /// Information about the series being created or updated.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct SeriesParameters<VideoCategoryId, VideoId> {
+pub struct SeriesParameters<VideoId> {
     // ?? It might just be more straighforward to always provide full list of seasons at cost of larger tx.
     /// If set, updates the seasons of a series. Extend a series when length of seasons is
     /// greater than previoulsy set. Last elements must all be 'Some' in that case.
     /// Will truncate existing series when length of seasons is less than previously set.
-    seasons: Option<Vec<Option<SeasonParameters<VideoCategoryId, VideoId>>>>,
+    seasons: Option<Vec<Option<SeasonParameters<VideoId>>>>,
     meta: Option<Vec<u8>>,
 }
 
@@ -649,7 +630,7 @@ decl_module! {
             origin,
             owner: ChannelOwner<T::MemberId, T::CuratorGroupId, T::DAOId>,
             assets: Vec<NewAsset<ContentParameters<T::ContentId, T::DataObjectTypeId>>>,
-            params: ChannelCreationParameters<T::ChannelCategoryId>,
+            params: ChannelCreationParameters,
         ) -> DispatchResult {
             Ok(())
         }
@@ -660,7 +641,7 @@ decl_module! {
             owner: ChannelOwner<T::MemberId, T::CuratorGroupId, T::DAOId>,
             channel_id: T::ChannelId,
             new_assets: Vec<NewAsset<ContentParameters<T::ContentId, T::DataObjectTypeId>>>,
-            params: ChannelUpdateParameters<T::ChannelCategoryId>,
+            params: ChannelUpdateParameters,
         ) -> DispatchResult {
             Ok(())
         }
@@ -710,7 +691,7 @@ decl_module! {
             owner: ChannelOwner<T::MemberId, T::CuratorGroupId, T::DAOId>,
             channel_id: T::ChannelId,
             assets: Vec<NewAsset<ContentParameters<T::ContentId, T::DataObjectTypeId>>>,
-            params: VideoCreationParameters<T::VideoCategoryId>,
+            params: VideoCreationParameters,
         ) -> DispatchResult {
             Ok(())
         }
@@ -721,7 +702,7 @@ decl_module! {
             owner: ChannelOwner<T::MemberId, T::CuratorGroupId, T::DAOId>,
             video: T::VideoId,
             assets: Vec<NewAsset<ContentParameters<T::ContentId, T::DataObjectTypeId>>>,
-            params: VideoUpdateParameters<T::VideoCategoryId>,
+            params: VideoUpdateParameters,
         ) -> DispatchResult {
             Ok(())
         }
@@ -927,7 +908,7 @@ decl_module! {
             owner: ChannelOwner<T::MemberId, T::CuratorGroupId, T::DAOId>,
             channel_id: T::ChannelId,
             assets: Vec<NewAsset<ContentParameters<T::ContentId, T::DataObjectTypeId>>>,
-            params: SeriesParameters<T::VideoCategoryId, T::VideoId>,
+            params: SeriesParameters<T::VideoId>,
         ) -> DispatchResult {
             Ok(())
         }
@@ -938,7 +919,7 @@ decl_module! {
             owner: ChannelOwner<T::MemberId, T::CuratorGroupId, T::DAOId>,
             channel_id: T::ChannelId,
             assets: Vec<NewAsset<ContentParameters<T::ContentId, T::DataObjectTypeId>>>,
-            params: SeriesParameters<T::VideoCategoryId, T::VideoId>,
+            params: SeriesParameters<T::VideoId>,
         ) -> DispatchResult {
             Ok(())
         }
@@ -1071,13 +1052,9 @@ decl_event!(
             ChannelId,
             ChannelOwner<MemberId, CuratorGroupId, DAOId>,
             Vec<NewAsset>,
-            ChannelCreationParameters<ChannelCategoryId>,
-        ),
-        ChannelUpdated(
-            ChannelId,
-            Vec<NewAsset>,
-            ChannelUpdateParameters<ChannelCategoryId>,
+            ChannelCreationParameters,
         ),
+        ChannelUpdated(ChannelId, Vec<NewAsset>, ChannelUpdateParameters),
         ChannelDeleted(ChannelId),
 
         ChannelCensored(ChannelId, Vec<u8> /* rationale */),
@@ -1101,16 +1078,8 @@ decl_event!(
         VideoCategoryUpdated(VideoCategoryId, VideoCategoryUpdateParameters),
         VideoCategoryDeleted(VideoCategoryId),
 
-        VideoCreated(
-            VideoId,
-            Vec<NewAsset>,
-            VideoCreationParameters<VideoCategoryId>,
-        ),
-        VideoUpdated(
-            VideoId,
-            Vec<NewAsset>,
-            VideoUpdateParameters<VideoCategoryId>,
-        ),
+        VideoCreated(VideoId, Vec<NewAsset>, VideoCreationParameters),
+        VideoUpdated(VideoId, Vec<NewAsset>, VideoUpdateParameters),
         VideoDeleted(VideoId),
 
         VideoCensored(VideoId, Vec<u8> /* rationale */),
@@ -1125,18 +1094,8 @@ decl_event!(
         PlaylistDeleted(PlaylistId),
 
         // Series
-        SeriesCreated(
-            SeriesId,
-            Vec<NewAsset>,
-            SeriesParameters<VideoCategoryId, VideoId>,
-            Series,
-        ),
-        SeriesUpdated(
-            SeriesId,
-            Vec<NewAsset>,
-            SeriesParameters<VideoCategoryId, VideoId>,
-            Series,
-        ),
+        SeriesCreated(SeriesId, Vec<NewAsset>, SeriesParameters<VideoId>, Series),
+        SeriesUpdated(SeriesId, Vec<NewAsset>, SeriesParameters<VideoId>, Series),
         SeriesDeleted(SeriesId),
 
         // Persons

+ 0 - 5
types/src/content/index.ts

@@ -36,7 +36,6 @@ export class ChannelOwner extends JoyEnum({
 
 export class Channel extends JoyStructDecorated({
   owner: ChannelOwner,
-  in_category: ChannelCategoryId,
   videos: Vec.with(VideoId),
   playlists: Vec.with(PlaylistId),
   series: Vec.with(SeriesId),
@@ -45,12 +44,10 @@ export class Channel extends JoyStructDecorated({
 }) {}
 
 export class ChannelCreationParameters extends JoyStructDecorated({
-  in_category: ChannelCategoryId,
   meta: Bytes,
 }) {}
 
 export class ChannelUpdateParameters extends JoyStructDecorated({
-  new_in_category: Option.with(ChannelCategoryId),
   new_meta: Bytes,
 }) {}
 
@@ -93,12 +90,10 @@ export class Video extends JoyStructDecorated({
 }) {}
 
 export class VideoCreationParameters extends JoyStructDecorated({
-  in_category: VideoCategoryId,
   meta: Bytes,
 }) {}
 
 export class VideoUpdateParameters extends JoyStructDecorated({
-  new_in_category: Option.with(VideoCategoryId),
   new_meta: Option.with(Bytes),
 }) {}