|
@@ -103,7 +103,6 @@ export class WebClientService {
|
|
|
private static ARGUMENT_RECEIVER_ID = 'id';
|
|
|
private static ARGUMENT_TEMPORARY_ID = 'temporaryId';
|
|
|
private static ARGUMENT_REFERENCE_MSG_ID = 'refMsgId';
|
|
|
- private static ARGUMENT_AVATAR = 'avatar';
|
|
|
private static ARGUMENT_AVATAR_HIGH_RESOLUTION = 'highResolution';
|
|
|
private static ARGUMENT_CONTACT_IS_TYPING = 'isTyping';
|
|
|
private static ARGUMENT_MESSAGE_ID = 'messageId';
|
|
@@ -220,7 +219,7 @@ export class WebClientService {
|
|
|
qrCodeService: QrCodeService,
|
|
|
mimeService: MimeService,
|
|
|
receiverService: ReceiverService,
|
|
|
- versionService: VersionService,
|
|
|
+ VersionService: VersionService,
|
|
|
CONFIG: threema.Config) {
|
|
|
|
|
|
// Angular services
|
|
@@ -243,7 +242,7 @@ export class WebClientService {
|
|
|
this.qrCodeService = qrCodeService;
|
|
|
this.mimeService = mimeService;
|
|
|
this.receiverService = receiverService;
|
|
|
- this.versionService = versionService;
|
|
|
+ this.versionService = VersionService;
|
|
|
|
|
|
// Configuration object
|
|
|
this.config = CONFIG;
|
|
@@ -1055,7 +1054,7 @@ export class WebClientService {
|
|
|
/**
|
|
|
* Send a add Contact request
|
|
|
*/
|
|
|
- public addContact(threemaId: string): Promise<threema.ContactReceiver> {
|
|
|
+ public addContact(threemaId: String): Promise<threema.ContactReceiver> {
|
|
|
return this._sendCreatePromise(WebClientService.SUB_TYPE_CONTACT, {
|
|
|
[WebClientService.ARGUMENT_IDENTITY]: threemaId,
|
|
|
});
|
|
@@ -1064,52 +1063,38 @@ export class WebClientService {
|
|
|
/**
|
|
|
* Modify a contact name or a avatar
|
|
|
*/
|
|
|
- public modifyContact(threemaId: string,
|
|
|
- firstName?: string,
|
|
|
- lastName?: string,
|
|
|
+ public modifyContact(threemaId: String,
|
|
|
+ firstName: String,
|
|
|
+ lastName: String,
|
|
|
avatar?: ArrayBuffer): Promise<threema.ContactReceiver> {
|
|
|
- // Prepare payload data
|
|
|
- const data = {};
|
|
|
- if (firstName !== undefined) {
|
|
|
- data[WebClientService.ARGUMENT_FIRST_NAME] = firstName;
|
|
|
- }
|
|
|
- if (lastName !== undefined) {
|
|
|
- data[WebClientService.ARGUMENT_LAST_NAME] = lastName;
|
|
|
- }
|
|
|
- if (avatar !== undefined) {
|
|
|
- data[WebClientService.ARGUMENT_AVATAR] = avatar;
|
|
|
- }
|
|
|
-
|
|
|
- // If no changes happened, resolve the promise immediately.
|
|
|
- if (Object.keys(data).length === 0) {
|
|
|
- this.$log.warn(this.logTag, 'Trying to modify contact without any changes');
|
|
|
- return Promise.resolve(this.contacts.get(threemaId));
|
|
|
- }
|
|
|
-
|
|
|
- // Send update
|
|
|
- const args = {
|
|
|
+ let promise = this._sendUpdatePromise(WebClientService.SUB_TYPE_CONTACT, {
|
|
|
[WebClientService.ARGUMENT_IDENTITY]: threemaId,
|
|
|
- };
|
|
|
- const promise = this._sendUpdatePromise(WebClientService.SUB_TYPE_CONTACT, args, data);
|
|
|
+ }, {
|
|
|
+ [WebClientService.ARGUMENT_FIRST_NAME]: firstName,
|
|
|
+ [WebClientService.ARGUMENT_LAST_NAME]: lastName,
|
|
|
+ [WebClientService.ARGUMENT_AVATAR_HIGH_RESOLUTION]: avatar,
|
|
|
+ });
|
|
|
|
|
|
- // If necessary, reset avatar to force a avatar reload
|
|
|
if (avatar !== undefined) {
|
|
|
- this.contacts.get(threemaId).avatar = {};
|
|
|
+ // reset avatar to force a avatar reload
|
|
|
+ this.receivers.getData({
|
|
|
+ type: 'contact',
|
|
|
+ id: threemaId,
|
|
|
+ } as threema.Receiver).avatar = {};
|
|
|
}
|
|
|
-
|
|
|
return promise;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Create a group receiver
|
|
|
*/
|
|
|
- public createGroup(members: string[],
|
|
|
- name: string = null,
|
|
|
+ public createGroup(members: String[],
|
|
|
+ name: String = null,
|
|
|
avatar?: ArrayBuffer): Promise<threema.GroupReceiver> {
|
|
|
- const data = {
|
|
|
+ let data = {
|
|
|
[WebClientService.ARGUMENT_MEMBERS]: members,
|
|
|
[WebClientService.ARGUMENT_NAME]: name,
|
|
|
- } as Object;
|
|
|
+ } as any;
|
|
|
|
|
|
if (avatar !== undefined) {
|
|
|
data[WebClientService.ARGUMENT_AVATAR_HIGH_RESOLUTION] = avatar;
|
|
@@ -1120,27 +1105,26 @@ export class WebClientService {
|
|
|
|
|
|
public modifyGroup(id: string,
|
|
|
members: String[],
|
|
|
- name?: String,
|
|
|
+ name: String = null,
|
|
|
avatar?: ArrayBuffer): Promise<threema.GroupReceiver> {
|
|
|
- // Prepare payload data
|
|
|
- const data = {};
|
|
|
- data[WebClientService.ARGUMENT_MEMBERS] = members;
|
|
|
- if (name !== undefined) {
|
|
|
- data[WebClientService.ARGUMENT_NAME] = name;
|
|
|
- }
|
|
|
+ let data = {
|
|
|
+ [WebClientService.ARGUMENT_MEMBERS]: members,
|
|
|
+ [WebClientService.ARGUMENT_NAME]: name,
|
|
|
+ } as any;
|
|
|
+
|
|
|
if (avatar !== undefined) {
|
|
|
- data[WebClientService.ARGUMENT_AVATAR] = avatar;
|
|
|
+ data[WebClientService.ARGUMENT_AVATAR_HIGH_RESOLUTION] = avatar;
|
|
|
}
|
|
|
-
|
|
|
- // Send update
|
|
|
- const args = {
|
|
|
+ let promise = this._sendUpdatePromise(WebClientService.SUB_TYPE_GROUP, {
|
|
|
[WebClientService.ARGUMENT_RECEIVER_ID]: id,
|
|
|
- };
|
|
|
- let promise = this._sendUpdatePromise(WebClientService.SUB_TYPE_GROUP, args, data);
|
|
|
+ }, data);
|
|
|
|
|
|
- // If necessary, reset avatar to force a avatar reload
|
|
|
if (avatar !== undefined) {
|
|
|
- this.groups.get(id).avatar = {};
|
|
|
+ // reset avatar to force a avatar reload
|
|
|
+ this.receivers.getData({
|
|
|
+ type: 'group',
|
|
|
+ id: id,
|
|
|
+ } as threema.GroupReceiver).avatar = {};
|
|
|
}
|
|
|
return promise;
|
|
|
}
|