|
diff --git a/.gitignore b/.gitignore |
|
index dd33554..20febc2 100644 |
|
--- a/.gitignore |
|
+++ b/.gitignore |
|
@@ -1 +1,2 @@ |
|
+.DS_Store |
|
.obsidian |
|
diff --git a/funcs.go b/funcs.go |
|
index 4449326..7566275 100644 |
|
--- a/funcs.go |
|
+++ b/funcs.go |
|
@@ -34,6 +34,9 @@ func ImportProfile(fromSession *AtprotoSession, toSession *AtprotoSession, dryru |
|
} |
|
profile := BskyActorProfile{} |
|
err = json.Unmarshal(getProfileResponse.Value, &profile) |
|
+ if err != nil { |
|
+ return errors.New(fmt.Sprintf("failed to parse source profile data: %v\n", err)) |
|
+ } |
|
|
|
newProfile := BskyActorProfile{ |
|
LexiconTypeID: "app.bsky.actor.profile", |
|
@@ -53,21 +56,25 @@ func ImportProfile(fromSession *AtprotoSession, toSession *AtprotoSession, dryru |
|
} |
|
|
|
if !dryrun { |
|
- // import avatar |
|
- avatarBytes, err := GetAtprotoBlob(fromSession.PdsUrl, fromSession.Did, profile.Avatar.Ref.Link) |
|
- if err != nil { return errors.New(fmt.Sprintf("failed to download avatar: %v\n", err)) } |
|
- |
|
- avatarBlob, err := UploadAtprotoBlob(toSession, avatarBytes, profile.Avatar.MimeType) |
|
- if err != nil { return errors.New(fmt.Sprintf("failed to upload avatar: %v\n", err)) } |
|
- newProfile.Avatar = avatarBlob |
|
+ if profile.Avatar != nil { |
|
+ // import avatar |
|
+ avatarBytes, err := GetAtprotoBlob(fromSession.PdsUrl, fromSession.Did, profile.Avatar.Ref.Link) |
|
+ if err != nil { return errors.New(fmt.Sprintf("failed to download avatar: %v\n", err)) } |
|
+ |
|
+ avatarBlob, err := UploadAtprotoBlob(toSession, avatarBytes, profile.Avatar.MimeType) |
|
+ if err != nil { return errors.New(fmt.Sprintf("failed to upload avatar: %v\n", err)) } |
|
+ newProfile.Avatar = avatarBlob |
|
+ } |
|
|
|
- // import banner |
|
- bannerBytes, err := GetAtprotoBlob(fromSession.PdsUrl, fromSession.Did, profile.Banner.Ref.Link) |
|
- if err != nil { return errors.New(fmt.Sprintf("failed to download banner: %v\n", err)) } |
|
+ if profile.Banner != nil { |
|
+ // import banner |
|
+ bannerBytes, err := GetAtprotoBlob(fromSession.PdsUrl, fromSession.Did, profile.Banner.Ref.Link) |
|
+ if err != nil { return errors.New(fmt.Sprintf("failed to download banner: %v\n", err)) } |
|
|
|
- bannerBlob, err := UploadAtprotoBlob(toSession, bannerBytes, profile.Banner.MimeType) |
|
- if err != nil { return errors.New(fmt.Sprintf("failed to upload banner: %v\n", err)) } |
|
- newProfile.Banner = bannerBlob |
|
+ bannerBlob, err := UploadAtprotoBlob(toSession, bannerBytes, profile.Banner.MimeType) |
|
+ if err != nil { return errors.New(fmt.Sprintf("failed to upload banner: %v\n", err)) } |
|
+ newProfile.Banner = bannerBlob |
|
+ } |
|
|
|
// import all details |
|
_, err = PutAtprotoRecord(toSession, "app.bsky.actor.profile", newProfile) |