-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/it/auties/whatsapp/model/message/model/PinInChat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package it.auties.whatsapp.model.message.model; | ||
|
||
import it.auties.protobuf.annotation.ProtobufEnumIndex; | ||
import it.auties.protobuf.annotation.ProtobufMessageName; | ||
import it.auties.protobuf.annotation.ProtobufProperty; | ||
import it.auties.protobuf.model.ProtobufEnum; | ||
import it.auties.protobuf.model.ProtobufMessage; | ||
import it.auties.protobuf.model.ProtobufType; | ||
import it.auties.whatsapp.model.info.MessageAddOnContextInfo; | ||
import it.auties.whatsapp.model.jid.Jid; | ||
import it.auties.whatsapp.util.Clock; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.Optional; | ||
|
||
|
||
/** | ||
* A model class that represents an ephemeral message that was saved manually by the user in a chat | ||
*/ | ||
@ProtobufMessageName("PinInChat") | ||
public record PinInChat( | ||
@ProtobufProperty(index = 1, type = ProtobufType.OBJECT) | ||
Type pinType, | ||
@ProtobufProperty(index = 2, type = ProtobufType.OBJECT) | ||
ChatMessageKey key, | ||
@ProtobufProperty(index = 3, type = ProtobufType.INT64) | ||
long clientTimestampInMilliseconds, | ||
@ProtobufProperty(index = 4, type = ProtobufType.INT64) | ||
long serverTimestampMilliseconds, | ||
@ProtobufProperty(index = 5, type = ProtobufType.OBJECT) | ||
MessageAddOnContextInfo messageAddOnContextInfo | ||
) implements ProtobufMessage { | ||
public Optional<ZonedDateTime> serverTimestamp() { return Clock.parseMilliseconds(serverTimestampMilliseconds); } | ||
|
||
public Optional<ZonedDateTime> clientTimestamp() { return Clock.parseMilliseconds(clientTimestampInMilliseconds); } | ||
|
||
public enum Type implements ProtobufEnum { | ||
UNKNOWN_TYPE(0), | ||
PIN_FOR_ALL(1), | ||
UNDO_PIN_FOR_ALL(2); | ||
|
||
final int index; | ||
|
||
Type(@ProtobufEnumIndex int index) { this.index = index; } | ||
|
||
public int index() { return index; } | ||
} | ||
} |