include description when migrating media

This commit is contained in:
Nicolas Constant 2019-03-10 19:50:09 -04:00
parent 1a1f4dccf6
commit b4fdce6e66
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 4 additions and 3 deletions

View File

@ -192,9 +192,10 @@ export class MastodonService {
} }
uploadMediaAttachment(account: AccountInfo, file: File): Promise<Attachment> { uploadMediaAttachment(account: AccountInfo, file: File, description: string): Promise<Attachment> {
let input = new FormData(); let input = new FormData();
input.append('file', file); input.append('file', file);
input.append('description', description);
const route = `https://${account.instance}${this.apiRoutes.uploadMediaAttachment}`; const route = `https://${account.instance}${this.apiRoutes.uploadMediaAttachment}`;
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` }); const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Attachment>(route, input, { headers: headers }).toPromise(); return this.httpClient.post<Attachment>(route, input, { headers: headers }).toPromise();

View File

@ -31,7 +31,7 @@ export class MediaService {
medias.push(wrapper); medias.push(wrapper);
this.mediaSubject.next(medias); this.mediaSubject.next(medias);
this.mastodonService.uploadMediaAttachment(account, file) this.mastodonService.uploadMediaAttachment(account, file, null)
.then((attachment: Attachment) => { .then((attachment: Attachment) => {
let currentMedias = this.mediaSubject.value; let currentMedias = this.mediaSubject.value;
let currentMedia = currentMedias.filter(x => x.id === uniqueId)[0]; let currentMedia = currentMedias.filter(x => x.id === uniqueId)[0];
@ -79,7 +79,7 @@ export class MediaService {
this.mediaSubject.next(medias); this.mediaSubject.next(medias);
for (let media of medias) { for (let media of medias) {
this.mastodonService.uploadMediaAttachment(account, media.file) this.mastodonService.uploadMediaAttachment(account, media.file, media.description)
.then((attachment: Attachment) => { .then((attachment: Attachment) => {
let currentMedias = this.mediaSubject.value; let currentMedias = this.mediaSubject.value;
let currentMedia = currentMedias.filter(x => x.id === media.id)[0]; let currentMedia = currentMedias.filter(x => x.id === media.id)[0];