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

Delete posts #27

Merged
merged 7 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion source/activities.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ export class Activities {
return this.postActivity(activity)
}

delete (activity) {
return this.postActivity({
type: 'Delete',
actor: this.actor.id,
object: typeof activity === 'string' ? activity : activity.id,
to: activity.to
})
}

mediaformat marked this conversation as resolved.
Show resolved Hide resolved
follow (targetId) {
return this.postActivity({
type: 'Follow',
Expand Down Expand Up @@ -400,7 +409,7 @@ export class Activities {
return this.postActivity({
type: 'Undo',
actor: this.actor.id,
object: activity.id,
object: typeof activity === 'string' ? activity : activity.id,
to: activity.to
})
}
Expand Down
16 changes: 16 additions & 0 deletions source/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,22 @@ export class ImmersClient extends window.EventTarget {
return this.activities.note(DOMPurify.sanitize(content), to, privacy)
}

/**
* Delete user's avatar from their Avatar Collection.
mediaformat marked this conversation as resolved.
Show resolved Hide resolved
* @param {(object|string)} sourceActivity - IRI of activity or Activity in the Outbox
* @returns {Promise<string>} IRI of the remove activity
*/
async deleteMessage (sourceActivity) {
switch (sourceActivity.type.toLowerCase()) {
case 'arrive':
return this.activities.undo(sourceActivity)
case 'leave':
return this.activities.undo(sourceActivity)
mediaformat marked this conversation as resolved.
Show resolved Hide resolved
case 'create':
return this.activities.delete(sourceActivity)
mediaformat marked this conversation as resolved.
Show resolved Hide resolved
}
}

/**
* Upload and/or share an image.
* When image is a canvas element, its toBlob method is used to generate a
Expand Down