Skip to content

Commit

Permalink
feat: add social like type (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
polebug authored Nov 26, 2024
1 parent 54f3df5 commit 96c9320
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ components:
- $ref: '#/components/schemas/SocialRevise'
- $ref: '#/components/schemas/SocialReward'
- $ref: '#/components/schemas/SocialShare'
- $ref: '#/components/schemas/SocialLike'
- $ref: '#/components/schemas/TransactionApproval'
- $ref: '#/components/schemas/TransactionBridge'
- $ref: '#/components/schemas/TransactionBurn'
Expand Down Expand Up @@ -463,6 +464,10 @@ components:
allOf:
- $ref: '#/components/schemas/SocialPost'
- type: object
SocialLike:
allOf:
- $ref: '#/components/schemas/SocialPost'
- type: object
TransactionApprovalAction:
type: string
enum:
Expand Down
1 change: 1 addition & 0 deletions openapi/Metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ oneOf:
- $ref: "./metadata/RSS.yaml"
- $ref: "./metadata/SocialComment.yaml"
- $ref: "./metadata/SocialDelete.yaml"
- $ref: "./metadata/SocialLike.yaml"
- $ref: "./metadata/SocialMint.yaml"
- $ref: "./metadata/SocialPost.yaml"
- $ref: "./metadata/SocialProfile.yaml"
Expand Down
3 changes: 3 additions & 0 deletions openapi/metadata/SocialLike.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allOf:
- $ref: "./SocialPost.yaml"
- type: object
3 changes: 2 additions & 1 deletion openapi/type/Social.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ enum:
- proxy
- revise
- reward
- share
- share
- like
2 changes: 1 addition & 1 deletion schema/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func unmarshalSocialMetadata(metadataType schema.Type, data json.RawMessage) (Me
var result Metadata

switch metadataType {
case typex.SocialComment, typex.SocialDelete, typex.SocialMint, typex.SocialPost, typex.SocialRevise, typex.SocialReward, typex.SocialShare:
case typex.SocialComment, typex.SocialDelete, typex.SocialMint, typex.SocialPost, typex.SocialRevise, typex.SocialReward, typex.SocialShare, typex.SocialLike:
result = new(SocialPost)
case typex.SocialProfile:
result = new(SocialProfile)
Expand Down
8 changes: 8 additions & 0 deletions schema/metadata/social.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ func (s SocialMint) Type() schema.Type {
return typex.SocialMint
}

var _ Metadata = (*SocialLike)(nil)

type SocialLike SocialPost

func (s SocialLike) Type() schema.Type {
return typex.SocialMint
}

//go:generate go run --mod=mod github.com/dmarkham/enumer@v1.5.9 --values --type=SocialProfileAction --transform=snake --trimprefix=ActionSocialProfile --output social_profile.go --json --sql
//go:generate go run --mod=mod github.com/rss3-network/enum-schema@v0.1.5 --type=SocialProfileAction --transform=snake --trimprefix=ActionSocialProfile --output ../../openapi/enum/SocialProfileAction.yaml -t ../../openapi/tmpl/Action.yaml.tmpl
type SocialProfileAction uint64
Expand Down
1 change: 1 addition & 0 deletions schema/typex/social.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ const (
SocialRevise
SocialReward
SocialShare
SocialLike
)
12 changes: 8 additions & 4 deletions schema/typex/social_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96c9320

Please sign in to comment.